Home » SQL & PL/SQL » SQL & PL/SQL » convert from MM-DD-YYYY to DD-MM-YYYY (ORACLE 9i)
convert from MM-DD-YYYY to DD-MM-YYYY [message #330599] Mon, 30 June 2008 09:50 Go to next message
NewLife
Messages: 170
Registered: April 2008
Senior Member
Hi,

How do i convert a date stored in the format MM-DD-YYYY to DD-MM-YYY , the column is of data type DATE.
Re: convert from MM-DD-YYYY to DD-MM-YYYY [message #330602 is a reply to message #330599] Mon, 30 June 2008 09:54 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
If the column is of DATE datatype it has no format.
Have a look at TO_CHAR function and associated model formats.

Regards
Michel
Re: convert from MM-DD-YYYY to DD-MM-YYYY [message #330750 is a reply to message #330599] Tue, 01 July 2008 02:13 Go to previous messageGo to next message
sreenu80
Messages: 50
Registered: July 2006
Location: bangalore
Member

Hi

You can use the TO_CHAR function.

TO_CHAR(sysdate,'DD-MM-YYYY')
TO_CHAR(columne name,'DD-MM-YYYY')

If it is any hard code date like '2008-03-02'

You need to first convert into the date data type by using TO_DATE and then u can use TO_CHAR to in which formare u want to print.

TO_CHAR(TO_DATE('2008-03-02','YYYY-MM-DD'),'DD-MON-YYYY')

And also what ever the column u want to be convert check first what is the data type of the column if it is date type u can directly use in the TO_CHAR.

TO_CHAR(columne name,'DD-MM-YYYY')

Other wise u need to fist convert into the Date data type and then use the TO_CAHR.

TO_CHAR(TO_DATE(column name,'YYYY-MM-DD'),'DD-MON-YYYY')


sreenu Smile
Re: convert from MM-DD-YYYY to DD-MM-YYYY [message #330753 is a reply to message #330750] Tue, 01 July 2008 02:19 Go to previous message
NewLife
Messages: 170
Registered: April 2008
Senior Member
Thanks Buddy Smile

Looks like we both are in the same place !!
Previous Topic: Insert/Delete Trigger
Next Topic: Joining two queries in one query
Goto Forum:
  


Current Time: Fri Dec 09 13:14:54 CST 2016

Total time taken to generate the page: 0.23624 seconds