Reputation: 19
I need to change the date format for an existing column in the table
select to_date(dob, 'dd/mm/yyyy') as myDate;
This is to select the date while displaying. I need to change the existing column like update it completely
Upvotes: 1
Views: 668
Reputation: 1270091
If you want to store the value as a string, I would recommend using the standard format YYYY-MM-DD and not depending on what a conversion routine returns:
update [table name]
set [col name] = to_char(to_date([col name], 'dd/mm/yyyy'), 'yyyy-mm-dd');
Upvotes: 0
Reputation: 1555
update [table name] set [col name] = to_date([col name], 'dd/mm/yyyy')
Upvotes: 1