UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> DateDiff() and the "w" interval    
(Difference between revisions)
Revision as of 06:32, 27 March 2010
DatAdrenaline (Talk | contribs)

← Previous diff
Revision as of 08:35, 4 May 2011
Jleach (Talk | contribs)
(added unport notif)
Next diff →
Line 1: Line 1:
 +{{Unport}}
 +
== Using the "w" setting in DateDiff() explained == == Using the "w" setting in DateDiff() explained ==
Line 29: Line 31:
---- ----
 +[[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. 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.

Revision as of 08:35, 4 May 2011

Image:NotifMove.png This article is part of the original Code Archive Porting process and should be moved to the Code Archive section or otherwise unported

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

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
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 datAdrenaline


Edit Discussion
Custom Search


Thank you for your support!
Disclaimers