project QadFinancials > class BBill > method GetDateOfXthWeekday
Description
Given a weekday W(1-7), a number X, a year Y and a month M, find Number Xth W in this certain month
Parameters
iiYear | input | integer | |
iiMonth | input | integer | |
iiNumber | input | integer | |
iiWeekday | input | integer | |
oiDay | output | integer | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bbill.p)
/* Find what is the day of the first day in the month */
viFirstWeekDay = Weekday(DATE(iiMonth, 1, iiYear)).
/* If the weekday of first day <= the target weekday, calculate day from the first week */
if viFirstWeekDay <= iiWeekday then do:
oiDay = 1 + iiWeekday - viFirstWeekDay + 7 * (iiNumber - 1).
end.
/* If the weekday of first day > the target weekday, calculate day from the next week */
else do:
oiDay = 1 + (iiWeekday + 7 - viFirstWeekDay) + 7 * (iiNumber - 1).
end.