khushbu1226
khushbu1226

Reputation: 23

How do I convert this oracle date

I am trying to convert from one date format to another. I am not sure how to write the functions.

My source date looks like 01/15/2009 01:23:15

The format I need is 01152009.

Thanks

Upvotes: 1

Views: 66

Answers (3)

Nate Rabenold
Nate Rabenold

Reputation: 56

Try this.

TO_CHAR(TO_DATE('01/15/2009 01:23:15','MM/DD/YYYY HH:MI:SS'),'MMDDYYY')

More info here, http://psoug.org/reference/date_func.html

Upvotes: 4

Shann
Shann

Reputation: 680

select TO_CHAR(TO_DATE('01/15/2009 01:23:15','MM/DD/YYYY MI:HH:SS'),'MMDDYYYY') from dual

if your field is already of data type date then you should only do:

select TO_CHAR(<fieldname>,'ddmmyyyy') ...

Upvotes: 0

kevinskio
kevinskio

Reputation: 4551

Does this work for you? It assumes the date is in date format but will work with timestamp

select to_char(YourDateField,'DDMMYYYY') from dual;

You can always convert it back to a date using the TO_DATE function if you need that format.

Upvotes: 0

Related Questions