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,
Routine validation between two dates
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.