Re: to_date('04-DEC-97 08:30','DD-MON-YY HH24:MI') will be 04-DEC-97 00:00 why?????

From: Alex Heney <a.j.heney_at_btNOinterSPAMnet.com>
Date: 1997/12/08
Message-ID: <348c1c0a.6429394_at_news.axion.bt.co.uk>#1/1


On Fri, 05 Dec 1997 15:11:07 GMT, linannie_at_ms16.hinet.net (annie) wrote:

>field name data type format
>-----------------------------------------------------------------------------
>DAY DATE DD-MON-YY
>START DATE HH24:MI
>if DAY is 04-DEC-97 , START is 08:30
>the data type of time1 is CHAR
>the data type of time2 is DATE
>
>I write :
>time1:=to_char(DAY)||' '||to_char(START);
>time2:=to_date(time1,'DD-MON-YY HH24:MI');
>
>the time1 will be '04-DEC-97 08:30' ---> it's data type is char
>why time2 will be 04-DEC-97 00:00
> ^^^^^^^
>WHY??? Please tell me! THANKS!

time1 will NOT contain '04-DEC-97 08:30', because START is of type DATE, which is stored on the database without the formatting you specified. To_Char(START) with no formatting specified will return the date in the default oracle format 'DD-MON-YY'. If the field only contains the time, then it will not return anything. You have to use

TO_CHAR(START,'HH24:MI') in order to return just the time part.

--

Alex Heney,  Global Villager

Remove NO and SPAM from the above address if replying by email.
Received on Mon Dec 08 1997 - 00:00:00 CET

Original text of this message