UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> DateDiff() and the "w" interval    
(Difference between revisions)
Revision as of 08:35, 4 May 2011
Jleach (Talk | contribs)
(added unport notif)
← Previous diff
Revision as of 14:27, 14 January 2012
DatAdrenaline (Talk | contribs)
(Removed attribution and 'unport' tag.)
Next diff →
Line 1: Line 1:
-{{Unport}} 
- 
== Using the "w" setting in DateDiff() explained == == Using the "w" setting in DateDiff() explained ==
Line 26: Line 24:
[http://www.utteraccess.com/forum/fNetWorkdays-fAddWorkDay-t1349593.html fNetWorkdays() and fAddWorkdays()] [http://www.utteraccess.com/forum/fNetWorkdays-fAddWorkDay-t1349593.html fNetWorkdays() and fAddWorkdays()]
[http://www.utteraccess.com/forum/Count-occurances-day-t1638262.html fCountWeekdays()] [http://www.utteraccess.com/forum/Count-occurances-day-t1638262.html fCountWeekdays()]
- 
-I realize that this little bit of information is touched on in the Access help file on the DateDiff() function, but with the confusion that is often associated around the "w" interval, I thought it was worth expanding upon. I hope you have found this information helpful. 
- 
- 
----- 
-[[Image:NotifLock.gif]]<br> 
-The content of this Acces Wiki article was migrated from the UtterAccess FAQA forum and can not be edited at this time. If you are the original author and would like the article unlocked as a standard wiki article, which enables editing by others, or you are a reader and have identified errors that warrant the removal of this article, please notify the Access wiki moderators. 
- 
-original article by [http://www.utteraccess.com/forum/datAdrenaline-m40232.html datAdrenaline] 
---- ----
[[Category:Access FAQ]] [[Category:Table of Contents]] [[Category:Access Wiki Index]] [[Category:Access FAQ]] [[Category:Table of Contents]] [[Category:Access Wiki Index]]

Revision as of 14:27, 14 January 2012

Using the "w" setting in DateDiff() explained

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() fCountWeekdays()


Edit Discussion
Custom Search


Thank you for your support!
Disclaimers