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

Home -> Community -> Usenet -> c.d.o.tools -> PL/SQL Date Arithmetic not working correctly!!

PL/SQL Date Arithmetic not working correctly!!

From: <newopt_at_my-deja.com>
Date: 2000/03/02
Message-ID: <89lti7$ia8$1@nnrp1.deja.com>#1/1

I do date arithmetic in the script that follows, but it is not calculating the correct number of days between 2 days? If SYSDATE and v_tgttstmp are both in the same month it works fine though?

I set the date format with the following statement in my 1st line of code:
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY MM DD'; For example: The following excerpt from my script subtarcts a date from a status table form SYSDATE:
v_tgttstmp is type DATE

Here's the output of the script when I run it using DBMS_output.put_line:
As you can see below SYSDATE = 2000 03 02, v_tgttstmp = 2000 02 28 and v_days = 2 when it should be 3?

SQL> @vantagestatus.sql
Session altered.
2000 03 022000 02 282
2000 03 022000 02 282
PL/SQL procedure successfully completed.

Here's the entire script:

ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY MM DD';
-- This PL/SQL generates a flat stanza file that is used by a Web
application
-- to provide a Vantage MidWest Extraction status for each of the
Vantage regions.
-- It reads from the vantage_region_status table, extracts the date and
time from the
-- last_extract_date column and applies the appropriate time zone. The
current
-- system date is then compared to the replication date and time for the

Any help would be appreciated!!

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu Mar 02 2000 - 00:00:00 CST

Original text of this message

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