Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Simple Date/time question.

Re: Simple Date/time question.

From: Medic Alert <news_at_medicalert.org>
Date: 1997/03/19
Message-ID: <33303F25.2C49@medicalert.org>#1/1

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.


> On Mon, 17 Mar 1997 16:21:59 +0000, Force12 Solutions Ltd
> <Force12_at_force12.com> wrote:
>
> >I understand you can have a combined date/time field in an Oracle
> >table. Is this true? If so, what format should the values be entered in?
Received on Wed Mar 19 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US