UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> DateDiff() and the "w" interval    
DateDiff() and the "w" interval

The "w" interval setting used in the DateDiff() expression can often cause confusion. The MS Access help file indicates that this interval is for "Weekdays". To some the term "Weekdays" means "Workdays" (ie: Monday through Friday), thus the confusion and claim that the "w" interval does not work. But the term "Weekdays" (thus the interval "w") actually means an indicated day of the week.

So ... with an expression like:

DateDiff("w", #4/1/2008#, #4/30/2008#)

The returned result is 4. Access looks at the start date of the indicated span and determines the day of the week the start date falls on, which is Tuesday in this case. Access will then count the number of Tuesdays between the dates indicated. Note that the start date is NOT included in the count.

Other samples:

DateDiff("w", #4/2/2008#, #4/30/2008#) -- returns 4 (the number of Wednesdays between the two dates)

DateDiff("w", #4/3/2008#, #4/16/2008#) -- returns 1 (the number of Thursdays between the two dates)

As a side note, the similar interval "ww" simply returns the number of Sundays between a date span.

Knowing how the "w" interval works can be quite handy when doing date calculations ...

For example, here are two archive posts that utilize the "w" interval of DateDiff():
fNetWorkdays() and fAddWorkdays()

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 7,548 times.  This page was last modified 01:02, 24 January 2012 by Jack Leach. Contributions by Brent Spaulding  Disclaimers