Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Trivia question re TO_DATE(SYSDATE)
Gary McFarling <gmcfarli_at_itind.com> wrote in message
news:7tluo0$kdg$1_at_republic.btigate.com...
> To_date() is a lovely way of parsing the date out of a dateTime data field
> of system object like sysdate. Another is Trunc() the two of these
together
> are designed and work quite well at killing, or making light of, the time
> that is inherently part of all Oracle dates. I guess I would be quite
> surprised if time survived the To_date() method.
Not true!
to_date() and trunc() are not the same. The expression to_date(sysdate) does NOT always clear out the time part, but trunc(sysdate) does do.
SQL> alter session set nls_date_format='YYYY/MM/DD HH24:MI:SS';
Session altered.
SQL> select to_date(sysdate) from dual;
TO_DATE(SYSDATE)
SQL> select trunc(sysdate) from dual;
TRUNC(SYSDATE)