Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TO_DATE() question...

Status
Not open for further replies.

pitz77

Programmer
Apr 27, 2004
14
US
TO_DATE('2004-10-25 10:36:22.0', 'mm/dd/rrrr'),


Here's the error:

ORA-01843: not a valid month


How the heck do I convert that datetime into mm/dd/rrrr?
 
'2004-10-25 10:36:22.0' is obviously a string, not datetime. And which calendar do you use, as the one I use contains only 12 months, while you complain that you can not get 2004-th month :)

Regards, Dima
 
When using to_date() function, the 2nd portion is used to show the format of the string that is placed the 1st part.

TO_DATE('2004-10-25 10:36:22.0', 'YYYY-MM-DD HH24:MI:SS'),

if you want ot transform the above to a different date format, then

to_char(TO_DATE('2004-10-25 10:36:22','YYYY-MM-DD HH24:MI:SS'),'mm/dd/yyyy')

or if you are using a table date field, then

TO_CHAR(table.datefield, 'mm/dd/yyyy')

The above is what I use in Oracle 8i. I'm not sure about the use of rrrr. In 8i, I can only use rr, which is the year relative to sysdate.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top