Number of days between two dates.

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

dls
Premium Member
Premium Member
Posts: 96
Joined: Tue Sep 09, 2003 5:15 pm

Post by dls »

I hope I'm not adding to the confusion. If I had access to DS390 and the mainframe, I would confirm whether or not that this date arithmetic can be done in the Transformer stage.

I'm paraphrasing from the DS390 documentation.......

If the default date format specified in project or job properties is 'YYYY-MM-DD', then CAST('2005-01-01' AS DATE) converts '2005-01-01' to a Date data type.

In DS390, when you move a Date data type to an Integer (w/o a date mask), the Date is converted to an Integer that represents the day number, where days are numbered sequentially from 0001-01-01 (which is day number 1).

If DAYS_DIFF is defined as an Integer, then I'm a little confused why it can't be derived as e.g., CAST(<date format 1> AS DATE) - CAST(<date format 2> AS DATE) :?
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

dls,

I think you're on to something there. I don't have DS390 access at the moment either to test things out.

I don't believe your expression would work as written though:
CAST(<date format 1> AS DATE) - CAST(<date format 2> AS DATE)
I think this would just end up as COBOL code subtracting PIC X(10) from PIC X(10), which obviously wouldn't work (but I can't test it to verify that theory).

Now, this could be tried:

Code: Select all

CAST (CAST(<date format 1> AS DATE) AS INT) - CAST (CAST(<date format 2> AS DATE) AS INT)
Not sure if a CAST will follow the conversion rule that you mention (days since 0001-01-01) or if it would give an integer like YYYYMMDD.

If the CAST AS INT doesn't do the trick, then it seems like it should be possible with 3 stage variables (where the conversion from date to integer seems like it should follow the number of days since 0001-01-01 conversion).

svDATE1 (integer): DATE1
svDATE2 (integer): DATE2
svDIF (integer): svDATE1 - svDATE2

Mike
dls
Premium Member
Premium Member
Posts: 96
Joined: Tue Sep 09, 2003 5:15 pm

Post by dls »

Where's a mainframe when you need one? :P
Post Reply