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: Different date format

Re: Different date format

From: Martin Haltmayer <Martin.Haltmayer_at_0800-einwahl.de>
Date: Sat, 05 May 2001 02:00:50 +0200
Message-ID: <3AF342B2.39D3787D@0800-einwahl.de>

Hello Erika,

select add_months(to_date(sysdate, 'DD-MON-YYYY'), -299) from dual;

does the following:

  1. Convert sysdate to a varchar2 with your nls_date_format active for that session. Because we do not know it I cannot tell you what is going on.
  2. Convert the resulting string by "to_date (..., 'DD-MON-YYYY')" to a date.
  3. Subtract 299 months from that date.
  4. Convert it to a varchar2 and display it.

The second statement "select add_months(sysdate, -299) from dual;" does the following:

  1. Subtract 299 months from sysdate.
  2. Convert it to a varchar2 and display it.

See the difference? The first one changes your date by converting it to a varchar2 and back to a date.

Martin Received on Fri May 04 2001 - 19:00:50 CDT

Original text of this message

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