Page 1 of 1
Routine validation between two dates
Posted: Tue Oct 12, 2004 12:40 pm
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,
Posted: Tue Oct 12, 2004 3:27 pm
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)