Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

number of working days in the previous month

Status
Not open for further replies.

e11a

IS-IT--Management
Jan 3, 2003
30
GB
Hello.

Is there a way to calculate the number of week days there were in the previous month?

Thanks,

E.
 
Here's a formula that should work:

whileprintingrecords;
numbervar days := day(cdate(year(currentdate),month(currentdate),1)-1);
numbervar x;
numbervar daycounter := 0;
datetimevar PrevMonth := dateadd("m",-1, currentdate);
for x:= 1 to days do(
if dayofweek(cdate(year(prevmonth),month(prevmonth),x)) in [2 to 6] then
daycounter := daycounter+1
);
Daycounter

-k
 
Thanks synapsevampire. That's brilliant.

E.
 
or :

DateVar TempDate := Minimum(lastfullmonth);
NumberVar DayCount := 0;
While TempDate <> Maximum(lastfullmonth)+1 do
(If not(dayofweek(TempDate) in [7,1]) then DayCount := Daycount + 1;
TempDate := TempDate + 1);
DayCount;

Reebo
Scotland (Sunny with a Smile)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top