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  

Date Difference Exclude Weekends



 
 
Thread Tools Display Modes
  #1  
Old June 13th, 2005, 03:20 PM
NadSadBad
external usenet poster
 
Posts: n/a
Default Date Difference Exclude Weekends

In a query, how can you calculate the difference between 2 dates (Date1 and
Date2) but exclude weekends.

I am trying to return the number of working days between 2 dates.

I know DateDiff only works for all days and includes weekends.

Thanks in advance
  #2  
Old June 13th, 2005, 03:33 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

See:
Workday Math
at:
http://www.mvps.org/access/datetime/date0012.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"NadSadBad" wrote in message
...
In a query, how can you calculate the difference between 2 dates (Date1
and
Date2) but exclude weekends.

I am trying to return the number of working days between 2 dates.

I know DateDiff only works for all days and includes weekends.

Thanks in advance



  #3  
Old June 13th, 2005, 03:37 PM
Dennis
external usenet poster
 
Posts: n/a
Default

I don't know if there is one so I wrote my own in a module and call this
instead

Function DateDiffXWE(stDate As Date, fiDate As Date) As Integer
Dim nDays As Integer

nDays = 0
While stDate fiDate
stDate = DateAdd("d", 1, stDate)
If Weekday(stDate) 1 And Weekday(stDate) 7 Then
nDays = nDays + 1
End If
Wend
DateDiffXWE = nDays
End Function

"NadSadBad" wrote:

In a query, how can you calculate the difference between 2 dates (Date1 and
Date2) but exclude weekends.

I am trying to return the number of working days between 2 dates.

I know DateDiff only works for all days and includes weekends.

Thanks in advance

 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
date ranges from a calculated date field John Feeley Running & Setting Up Queries 1 May 26th, 2005 06:53 AM
Date exclude weekdays LukePW New Users 9 December 20th, 2004 05:00 PM
Date Difference Code Help Needed! Dave Elliott Using Forms 2 October 31st, 2004 03:56 PM
more dates!!! brigid Running & Setting Up Queries 6 May 26th, 2004 10:59 AM
Formula to calculate date difference Brigitte D'Andrea Worksheet Functions 4 November 3rd, 2003 06:34 PM


All times are GMT +1. The time now is 06:08 PM.


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