I'm a new in SQL and I'm trying to convert a column of type varchar(255)
to datetime
(yyyy-mm-dd). I found some advice to convert one element but how can I convert entire column to a new datatype?
My table is mydemo
and the column to convert is ordertime
and it contains only valid datetime strings lie this:
Could someone please help me?
if all the rows have valid datetime values you can do it using command below:
alter table mydemo
alter column ordertime type timestamp USING ordertime::timestamp without time zone;