Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate number of Work Days between 2 dates

Status
Not open for further replies.

addy

Technical User
May 18, 2001
743
GB
Hi

As part of a task capture system I will be recording the date & time of a task being received and then the date and time the task is completed.

I would then like to calculate how many working days this task to complete - i.e. ignore Saturdays and Sundays.

So, if a task is received 9.00am Thursday morning and is completed 9.00am Tuesday morning then the time taken is 3 working days.

Any help, as always, would be most appreciated.
 
An Advanced Search should yield a number of posts on this subject. There are also a few FAQs. Here is one:
Calculate working days between two dates
faq181-261
 
i would create a Table with numbers from 1 to .......(as many as you think you could need (my digits table goes to 1,000,000))


Code:
Dim mydb As Database
Dim rst As Recordset
Set mydb = CurrentDb
Dim startdate As Date
Dim Enddate As Date
startdate = #10/20/2006#
Enddate = #11/15/2006#
Set rst = mydb.OpenRecordset("SELECT DateAdd('d',[digitid]-1,#" & startdate & "#) FROM Digits WHERE (((DateAdd('d',[digitid]-1,#" & startdate & "#)) Not In (1,7)) AND ((DateAdd('d',[digitid]-1,#" & startdate & "#))<=#" & Enddate & "#) AND (([DigitID]-1)<364));")
rst.MoveLast
Debug.Print rst.RecordCount

change startdate and enddate to your dates
 
Thanks for all your replies - have found the info I need.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top