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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |