oracle - convert date in sql using to_char function -
i convert following date format(dd-mon-yyyy).
i tried executing below query got error saying "date format not recognised".
select to_char(to_date('sat dec 01 00:00:00 ist 2012','eee mon dd hh:mm:ss z yyyy'),'dd-mon-yyyy') dual;
for time zone:
'dy mon dd hh24:mi:ss yyyy'
for timezone support need use conversion function supports timezone to_timestamp_tz() , have time zone name 1 oracle recognizes in form recognizes.
select to_char( to_timestamp_tz( replace( 'sat dec 01 21:00:00 ist 2012','ist','asia/calcutta'), 'dy mon dd hh24:mi:ss tzr yyyy'),'dd-mon-yyyy') dual;
the relation between time zone names , abbreviations 1 many most.
select tzname, tzabbrev v$timezone_names tzabbrev = 'ist'
for example easier remove or of date parts don't need in output before conversion.
select to_char( to_date( replace('sat dec 01 21:00:00 ist 2012','ist',''), 'dy mon dd hh24:mi:ss yyyy'),'dd-mon-yyyy') dual;
Comments
Post a Comment