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

Home -> Community -> Usenet -> c.d.o.server -> Re: Date/Time Conversions?

Re: Date/Time Conversions?

From: Sergey Kaplun <skaplun_at_my-deja.com>
Date: Wed, 02 Jun 1999 10:52:41 GMT
Message-ID: <7j32dm$gpt$1@nnrp1.deja.com>


In article <7j19sm$su$1_at_nnrp2.deja.com>,   grider22_at_my-deja.com wrote:
> Hi,
>
> I have a character string: '19990315' that I need to derive into a
date
> field. However, when I use the TO_DATE function it will convert
> '19990315' to '15-MAR-1999'. This format gives me an invalid date
> error. Is there anyway to convert '19990315' string into a date but
> still retain the same format? I would also like to do the same thing
for
> a time string of '1450' and derive this into a time field.
>
> Thanks,
> Stephen
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>

Hi Stephen,
Oracle stores date and time together in special internal format. You can convert your strings to date format and vice versa. Look at this example:
sql> select to_char(to_date('199903151450','yyyymmddmiss'),

     'dd-mm-yy mi:ss') from dual;

to_date('199903151450','yyyymmddmiss') <- converts data&time to internal
format (according to format 'yyyymmddmiss')
to_char(<date-datatype-value>,'your-desirable-format') <- converts date
to string (according to specified format).

Best regards,
Sergey.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Wed Jun 02 1999 - 05:52:41 CDT

Original text of this message

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