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 -> R: Trivia question re TO_DATE(SYSDATE)

R: Trivia question re TO_DATE(SYSDATE)

From: Riccardo Ferrari <riccardo.ferrari_at_informatica2.it>
Date: Thu, 14 Oct 1999 17:48:13 +0200
Message-ID: <7u4u60$au3$1@nslave1.tin.it>


The full explanation can be this:
TO_DATE(SYSDATE) works because of the internal conversions Oracle makes for you.
This means tha TO_DATE(SYSDATE) is a (useless and dangerous) shortcut for: TO_DATE(TO_CHAR(SYSDATE, <nls_date_format>), <nls_date_format>); In the inner conversion you can loose precision according to the date format. When you reconvert in date the missing precision is filled in the default way that for time is 00.00.00.

What happens if you have not SYSDATE but a date variable (say MY_DATE)containing the internal oracle date representation of '15 October 2001' with nls_date_format = 'ddmmyy'?
Simple but terrible: TO_DATE(MY_DATE) = the internal oracle date representation of '15 October 1901' ... and it's not a MILLENIUM BUG!!!!! Regards,
Riccardo

> Ah, that makes sense... I'm guessing that the reason the time is only
> truncated occasionally is that sometimes NLS_DATE_FORMAT is set to the
> default 'DD-MON-YY', and sometimes it's set to 'DD-MON-YY HH:MM:SS' (or
> some format like that - I'm just guessing). In this application that's
> quite possible...
>
> I think it's time I hit the manuals (this is my first serious Oracle
> adventure). Thanks for the explanation!
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Thu Oct 14 1999 - 10:48:13 CDT

Original text of this message

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