'How to Convert A' MM/YY' String in to a date format 'YYYY-MM-01' in Postgresql
I have column of string, and it's like 'MM YY' (eg. Dec 21, Jan 22, etc..). How can I convert it to a date format, YYYY-MM-DD, in Redshift.(PostgreSQL) Thanks!
Solution 1:[1]
If you want to convert to Date, you can use:
TO_DATE(column, 'Mon YY')
If you want to convert to Text (String), you can use:
TO_DATE(column, 'Mon YY')::TEXT
This uses the TO_DATE - Amazon Redshift function to "convert a date represented by a character string to a DATE data type."
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | John Rotenstein |
