sql - Convert mm/dd/yyyy to yyyy-mm-dd in Oracle -
the date column have in varchar2
, want convert values in yyyy-mm-dd
date 7/26/2013 7/29/2013 8/1/2013 8/4/2013 7/28/2013 7/31/2013 8/3/2013 7/30/2013 8/5/2013 7/25/2013 8/2/2013 8/6/2013 7/27/2013
you should never store dates in varchar
column
so in order display differently now, need first convert string date , string
if "dates" have right (and same) format, following should work:
select to_char(to_date(date, 'mm/dd/yyyy'), 'yyyy-mm-dd') the_table;
but wouldn't surprised if gives error because 1 or more rows have date formatted differently. not have happened had defined column of type date
right beginning.
you should really, consider changing column real date
column.
btw: date
horrible name such column. reserved word , doesn't tell stored in column (a "start date", "end date", "birth date", "due date", ...)
Comments
Post a Comment