I am trying to take what is currently stored in ViewPoint as a Script that is run and convert it over to SQL and scheduled Tasks. My issue is well simply put I don't know the scripting language used for I Series. Can anyone tell me what the resulting value will be for &STARTS &STARTS2 and &STARTS3
CHGVAR VAR(&OFFSET) VALUE(0)
CHGVAR VAR(&STARTS) VALUE(CYYMMDD(DATE(MONTH(Current Date- (&OFFSET + 1) Month)||'/22/'||YEAR(Current Date-(&OFFSET+1) month))))
CHGVAR VAR(&STARTS2) VALUE(CYYMMDD(DATE(MONTH(Current Date- (&OFFSET + 2) Month)||'/22/'||YEAR(Current Date-(&OFFSET+2) month))))
CHGVAR VAR(&STARTS3) VALUE(CYYMMDD(DATE(MONTH(Current Date- (&OFFSET + 3) Month)||'/22/'||YEAR(Current Date-(&OFFSET+3) month))))
One of the relatively nifty things about the iSeries is that it lets you do 'natural language' date math: current_date - 2 months
is exactly what it sounds like, a date that is precisely two months before today.
So, assuming that it actually works as written, what this script is doing is:
&OFFSET
to 0. (the CHGVAR
command is the iSeries's verbose way of assigning a value: in most languages you would write &OFFSET = 0
instead, and even with the iSeries you could shorten it to simply CHGVAR &OFFSET 0
.)&STARTS
to the 22nd of last month, where the date is in the CYYMMDD format. (It does this by constructing the date based on "use the month that is one month before today, 22 as the day, and the year of the month that is one month before today", and then converting that to CYYMMDD format. &STARTS2
to the 22nd of 2 months ago &STARTS3
to the 22nd of 3 months agoIf you were to tweak the value of &OFFSET
(by changing its VALUE(0)
assignment), your calculated dates would be that much further in the past: setting it to VALUE(4)
would get you dates of 5, 6, and 7 months ago.
In the CYYMMDD format, by the way, the 'C' is a counter of centuries since 1900; essentially, the date is an integer of the form YYYYMMDD - 19000000. So, 1/1/1999 = 19990101 in YYYYMMDD format, or 0990101 in CYYMMDD format; 12/31/2011 = 20111231 in YYYYMMDD format, or 1111231 in CYYMMDD format.
So if you ran this today, 8/19/2015, you should get results of:
By the way, the language your script is written in is called "CL" (short for "Command Language"), and the official language reference is at The IBM Knowledge Center.