Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Simple Date/time question.
Ed Hillmann wrote:
>
> I think the default is hh24miss, which is six digits containing the 24
> hour, minutes and seconds. So, 1:05:32 PM on Feb 1 would be
> '01-Feb-97 130532'.
>
> However, check out the TO_CHAR() function, which is the converse
> function to the TO_DATE() function. You can use the TO_CHAR function
> to convert a string containing a date to a date/time value. It takes
> two parameters, the string and a formula Oracle can use to convert it.
> Something like....
>
> TO_CHAR('02/01/97 13:05:32','MM/DD/YY HH24:MI:SS')
No. TO_CHAR will not convert a string to a date. It
converts data of various types (including DATE) to strings.
When used with dates, TO_CHAR requires a DATE as the
first argument and yields a text version of the date.
Using TO_CHAR this way not only wouldn't work, and
wouldn't yield a date (which is what the question
was originally), but even if you used correct syntax
to make it work...
TO_CHAR(TO_DATE('02/01/97 13:05:32','MM/DD/YY HH24:MI:SS'),'MM/DD/YY HH24:MI:SS')
....what have you accomplished? You've converted a string to a date, then back to a string! Not exactly productive use of CPU time!
TO_DATE converts strings to DATES, not TO_CHAR.
![]() |
![]() |