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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DayOfWeek 1

Status
Not open for further replies.

Roni1

Programmer
Dec 4, 2001
36
0
0
US
How can I count how many DayOfWeek in [1,7] for a date range? Example: How mayy Saturdays and Sundays from 1/1/08 tru 6/30/08?
 
//Countwends
if dayofweek({date.field}) in [1,7] then 1 else 0

Sum on this through a running total or summary as appropriate to your needs (Read totals FAQ if unsure)

'J
 
This seems to work:

datevar start := {?start};
datevar end := {?end};
numbervar sats;
numbervar suns;
sats := datepart("ww",end,crSaturday)-datepart("ww",start,crSaturday);
suns := datepart("ww",end,crSunday)-datepart("ww",start,crSunday);
if dayofweek(start,CrSaturday) = 1 then
sats := sats +1 ;
if dayofweek(start, crSunday) = 1 then
suns := suns + 1;
"Sats: "+totext(sats,0,"") + " Suns: "+totext(suns,0,"")

-LB
 
Thank you LB, that was right on the money!

I am sorry that took too long for me to respond.

Cheers!
Roni
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top