I would like to determine the last date of the previous month in a routine that I later pass as paramter to a job. For example, today I should get 07-31-2005.
I will appreciate your help.
Thanks.
Determining the last date of previous month
Moderators: chulett, rschirm, roy
Kim,
Thanks for the reply. I still can't figure out how to get the first date of the month. However I know how I can do that in a transformer using the following code:
DATE.TAG(MONTH.FIRST((MONTH.TAG(@DATE))) - 1)
So I just pasted the same line in the routine which looks as below but gives me compile error. Please help me understand what is going on here.
Thanks.
Code in the routine:
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
CurrDate = DATE.TAG(MONTH.FIRST((MONTH.TAG(@DATE))) - 1)
Ans = CurrDate
Compile error:
Compiling: Source = 'DSU_BP/DSU.pqpCreateCtrlFile', Object = 'DSU_BP.O/DSU.pqpCreateCtrlFile'
**************************************
Array 'DATE.TAG' never dimensioned.
Array 'MONTH.FIRST' never dimensioned.
Array 'MONTH.TAG' never dimensioned.
Thanks for the reply. I still can't figure out how to get the first date of the month. However I know how I can do that in a transformer using the following code:
DATE.TAG(MONTH.FIRST((MONTH.TAG(@DATE))) - 1)
So I just pasted the same line in the routine which looks as below but gives me compile error. Please help me understand what is going on here.
Thanks.
Code in the routine:
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
CurrDate = DATE.TAG(MONTH.FIRST((MONTH.TAG(@DATE))) - 1)
Ans = CurrDate
Compile error:
Compiling: Source = 'DSU_BP/DSU.pqpCreateCtrlFile', Object = 'DSU_BP.O/DSU.pqpCreateCtrlFile'
**************************************
Array 'DATE.TAG' never dimensioned.
Array 'MONTH.FIRST' never dimensioned.
Array 'MONTH.TAG' never dimensioned.
You need to search for DEFFUN to call these functions. First of the month is easy. You need to oconv(@DATE, "D4-") then substring it to get year and month then put it back together.
Code: Select all
Today = oconv(@DATE, "D4-")
ThisYear = field(Today, "-", 3)
ThisMonth = field(Today, "-", 1)
FirstOfMonth = ThisMonth : "-01-" : ThisYear
EndOfLastMonth = oconv(iconv(FirstOfMonth, "D4-") - 1, "D4-")
Mamu Kim
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
DATE.TAG, MONTH.FIRST and MONTH.LAST are Transforms and can't be loaded into routines directly. You can, however, load their defining expressions. You may still need to include JOBCONTROL.H. Or, refining Kim's routine into a single expression:
Code: Select all
Oconv(Iconv(Oconv(@DATE, "D-YM[4,2]"):"-01", "DYMD") - 1, "D-YMD[4,2,2]")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: