ginkoba
Technical User
- Jan 29, 2009
- 60
I'm using the below formula to derive the exact number of working days(-sat, sun) for the last full month. For some reason, each month, I have to manually adjust for 1 or a couple of days depending if the month has 30 or 31 days. I thought my formula was doing this automatically but some how, its not. Can someone please take a look and let me know.
NumberVar v_monthvalue;
if month(currentdate) in [4,6,9,11]
then v_monthvalue := 32
else if month(currentdate) = 2
then v_monthvalue := 28
else v_monthvalue := 29;
Local DateTimeVar d1 := CurrentDate-v_monthvalue;
Local DateTimeVar d2 := CurrentDate;
DateDiff ("d", d1, d2) -
DateDiff ("ww", d1, d2, crSaturday) -
DateDiff ("ww", d1, d2, crSunday)
NumberVar v_monthvalue;
if month(currentdate) in [4,6,9,11]
then v_monthvalue := 32
else if month(currentdate) = 2
then v_monthvalue := 28
else v_monthvalue := 29;
Local DateTimeVar d1 := CurrentDate-v_monthvalue;
Local DateTimeVar d2 := CurrentDate;
DateDiff ("d", d1, d2) -
DateDiff ("ww", d1, d2, crSaturday) -
DateDiff ("ww", d1, d2, crSunday)