A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

days between 2 dates w/o weekends



 
 
Thread Tools Display Modes
  #1  
Old August 23rd, 2006, 09:15 PM posted to microsoft.public.access.queries
2Blessed4Stress
external usenet poster
 
Posts: 30
Default days between 2 dates w/o weekends

I am calculating the days between 2 dates in my qry using the DateDiff
function in my qry. How can I omit weekends from my day count?
  #2  
Old August 23rd, 2006, 10:08 PM posted to microsoft.public.access.queries
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default days between 2 dates w/o weekends

Hi

Create a new module and paste this into it

Function CountWODays(Date1 As Date, Date2 As Date) As Long
Dim DayCntr As Long, LoopDate As Date, WD As Long
DayCntr = 0
For LoopDate = Date1 To Date2
WD = Weekday(LoopDate)
If WD 1 And WD 7 Then '1-Sunday 7-Saturday
DayCntr = DayCntr + 1
End If
Next LoopDate
End Function


Save it and then in your query you can call it by putting something like in
the criteria section

WeekdaysCount: CountWODays([StartDate],[EndDate])



Hope this helps


--
Wayne
Manchester, England.
Not an expert
Enjoy whatever it is you do


"2Blessed4Stress" wrote:

I am calculating the days between 2 dates in my qry using the DateDiff
function in my qry. How can I omit weekends from my day count?

  #3  
Old August 23rd, 2006, 10:11 PM posted to microsoft.public.access.queries
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default days between 2 dates w/o weekends

Take a look at the Date/Time section of "The Access Web" for a couple of
possiblities http://www.mvps.org/access/datetime/ or take a look at my
September, 2004 "Access Answers" column in Pinnacle Publication's "Smart
Access".

You can download the column (and sample database) from
http://www.accessmvp.com/DJSteele/SmartAccess.html

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"2Blessed4Stress" wrote in
message ...
I am calculating the days between 2 dates in my qry using the DateDiff
function in my qry. How can I omit weekends from my day count?



  #4  
Old August 23rd, 2006, 10:24 PM posted to microsoft.public.access.queries
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default days between 2 dates w/o weekends

Hi Douglas.

I just open you pdf regarding simulated checkoxes (windings font).

Can I just say I thought it was really good. Thanks for the tips. It is
one of the question I get asked quite often (can you make that box bigger) I
have always said no but from now .....

Thanks


--
Wayne
Manchester, England.
Not an expert
Enjoy whatever it is you do


"Douglas J. Steele" wrote:

Take a look at the Date/Time section of "The Access Web" for a couple of
possiblities http://www.mvps.org/access/datetime/ or take a look at my
September, 2004 "Access Answers" column in Pinnacle Publication's "Smart
Access".

You can download the column (and sample database) from
http://www.accessmvp.com/DJSteele/SmartAccess.html

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"2Blessed4Stress" wrote in
message ...
I am calculating the days between 2 dates in my qry using the DateDiff
function in my qry. How can I omit weekends from my day count?




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:41 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.