Re: format date with Oracle Dynamic SQL

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Wed, 2 Mar 2005 04:25:45 -0500
Message-ID: <E-CdnSmDNK8GG7jfRVn-iQ_at_comcast.com>


<deadlocklegend_at_gmail.com> wrote in message news:1109731580.120769.164910_at_g14g2000cwa.googlegroups.com...
> sorry about bothering you, but when i do something like
>
> select to_date(to_char(date_column, 'yyyy-mm-dd hh24:mi:ss'),
> 'yyyy-mm-dd hh24:mi:ss') from table_name
>
> in my pro*c code, i get back
>
> 2005-02-24 00:00:00
>
> when data is 2005-02-24 11:05:07
>

the TO_DATE is using the default date format (NLS_DATE_FORMAT) to convert back to a date column -- that is likely truncating the time element

if you want a date, don't use either to_date or to_char

if you need to convert to or from a date datatype, us to_date or to_char (seldom are both ever used together) with the appropirate date format -- or use ALTER SESSION to set the default date format for your session

++ mcs Received on Wed Mar 02 2005 - 10:25:45 CET

Original text of this message