Routine validation 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

Post Reply
Emilio
Participant
Posts: 17
Joined: Wed Jan 28, 2004 2:18 pm
Location: Frederick, MD

Routine validation between two dates

Post by Emilio »

I need to write a routine that validates a date is between two dates:
1) See that the date checked is between the 1st day of the prior month (based on the current/system date) and (2) the 15th of the current month.
Any clues how to do this?
Thanks,
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

FUNCTION CheckDate(TheDate)
* TheDate is expected to be in DataStage internal format

* Calculate internal forms of boundary dates
ThisMonth = @MONTH
PrevMonth = ThisMonth - 1
ThisYear = @YEAR
PrevYear = ThisYear - 1
If PrevMonth <= 0
Then
   PrevYear = ThisYear -1
   PrevMonth += 12
End

FirstOfPrevMonth = Fmt(PrevYear, "R%4") : Fmt(PrevMonth, "R%2") : "01"
FirstOfPrevMonth = Iconv(FirstOfPrevMonth, "DYMD")
FifteenthOfCurrentMonth = ThisYear : Fmt(ThisMonth, "R%2") : "15"
FifteenthOfCurrentMonth = Iconv(FifteenthOfCurrentMonth, "DYMD")

* Perform range check
Ans = (TheDate >= FirstOfPreviousMonth And TheDate <= FifteenthOfCurrentMonth)
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply