I have a VARCHAR data type in a order_date column which contains dates, I would like to convert it to DATE format except for null values. How can I solve this?
Question posted in PostgreSQL
The official documentation can be found here.
The official documentation can be found here.
3
Answers
Where is an problem?
You need use
TO_DATE(column_name,'YYYYMMDD')
Specify the format of the date in the varchar field the way it is as second input parameter to the
TO_DATE
functionand
apply filter
where column_name is not null
You can refer to this documentation for further reference.
You should use them!
Here is the link to the related doc: https://www.postgresql.org/docs/current/functions-formatting.html
The above depends on your Postgres version. However,
to_date(text, text)
must work.