Set the datestyle before:
set datestyle = mdy;
Question
I'm trying to cast a varchar into a date with this following code, and the following error is outputting, any idea why?
ALTER TABLE import.employee
ALTER COLUMN birth_date
TYPE date
USING (birth_date::date);
ERROR: date/time field value out of range: "05/29/1960"
HINT: Perhaps you need a different "datestyle" setting.
********** Error **********
ERROR: date/time field value out of range: "05/29/1960"
SQL state: 22008
Hint: Perhaps you need a different "datestyle" setting.
Solution
Set the datestyle before:
set datestyle = mdy;
OTHER TIPS
If you need to get the ::date from birth_date, first give the DATE format to your field using the given functions in Data Type Formatting Functions docs.