how to count days between...?

# Thread: how to count days between...?

1. Senior Member
Join Date
Dec 1969
Posts
158

## how to count days between...?

Hello All,<BR><BR>How to count number of work days (without weekends) between two dates? thanks a lot!

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## What happens...

...if one of the dates is *ON* a weekend??? <BR><BR>What do you want to do then?<BR><BR>But it&#039;s not too hard:<BR><BR>&#060;%<BR>startDate = CDATE( ... ) &#039; be *SURE* these are DATE values!<BR>endDate = CDATE( ... )<BR><BR>&#039; find weekday of each<BR>startWD = Weekday(startDate)<BR>endWD = Weekday(endDate)<BR><BR>&#039; back up both dates to start of week<BR>&#039; (actually, to last day of week previous)<BR>startFirst = startDate - startWD<BR>endFirst = endDate - endWD<BR><BR>&#039; find number of weeks between those:<BR>weeks = DateDiff( "w", startFirst, endFirst )<BR><BR>&#039; and 5 days per week:<BR>days = weeks * 5<BR><BR>&#039; but then adjust for the starting days...<BR>&#039; WORK IT OUT! Understand why and how it gives the answer:<BR>&#039;<BR>days = days - startWD + endWD<BR>%&#062;<BR>

3. Senior Member
Join Date
Dec 1969
Posts
158

## really a Master !

thanks...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•