I have written a Newspaper Carrier program that only delivers on Monday-Saturday. I need to know how to determine how many Sundays are within a certain date range and then subtract them from the total days calculated so I will come up with the correct days to bill for.
I have the following code:
Code:
IF PIA:PrepaidFor = '1 Month'
PayMonth = Month(PIA:ReceivedFrom)
IF PayMonth = 1 OR PayMonth = 3 OR PayMonth = 5 OR PayMonth = 7 OR PayMonth = 8 OR PayMonth = 10 OR PayMonth = 12
PIA:ReceivedTo = PIA:ReceivedFrom + 31
ELSIF PayMonth = 4 OR PayMonth = 6 OR PayMonth = 9 OR PayMonth = 11
PIA:ReceivedTo = PIA:ReceivedFrom + 30
ELSE
PIA:ReceivedTo = PIA:ReceivedFrom + 28
END
END
Example:
If PIA:ReceivedFrom = 07/08/2015
PIA:ReceivedTo = 08/08/2015 with only 4 Sundays in between. This is the correct answer.
But if PIA:ReceivedFrom = 07/10/2015
PIA:ReceivedTo = 08/09/2015 but should be 08/10/2015 because there are 5 Sundays in between.
How do I determine there are 5 Sundays so I can add an extra day to PIA:ReceivedTo.