![]() PostgreSQL native data, we need to run the following: SELECT '10. It returns an error because the DOUBLE type is not a type of The most common date formats used are: MM / DD / YYYY, MM-DD-YYYY, MM-DD-YY, MM / DD / YY, YYYY / MM / DD, YYYY-MM-DD.Īs in the previous case, if the date is not valid, it will return an error: Numerical conversions with CAST Example 3: String a In that case, the conversion can be done with the command: SELECT CAST ('01 -01-1990 'AS DATE) ![]() It is usually used in case of need operate on a date, such as calculating the age of an employee. That the text is alphanumeric, since it would give you an error: SELECT '100ab' :: integer Example 2. This conversion is not possible in the case If we need to perform any mathematical operation on a field of type STRING we can do the following conversion: SELECT '100' :: integer Syntax without problem, since the result is the same: expression :: typeĪn example may be the converting the number 97 to a String type, it can be done in the following ways: SELECT CAST (97 AS varchar) Ĭonversions with CAST Example 1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |