user11366750
user11366750

Reputation: 19

Need to change the date format of an entire column

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

Answers (2)

Gordon Linoff
Gordon Linoff

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

Programnik
Programnik

Reputation: 1555

update [table name] set [col name] = to_date([col name], 'dd/mm/yyyy')

Upvotes: 1

Related Questions