Question

Please I need help on how to convert this string [ Fri Jun 19 10:45:39 EDT 2009 ] that is in EDT date format back to Date in SQL (Am using Postgres). I want to be able to have something like this 19-06-2009

Thanks

Was it helpful?

Solution

SELECT
    CAST('Fri Jun 19 10:45:39 EDT 2009' AS date),   -- to get datatype DATE
    TO_CHAR(CAST('Fri Jun 19 10:45:39 EDT 2009' AS date), 'DD-MM-YYYY') -- formated date, a string
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top