View Full Version : Number of days


deejay_totoro
10-28-2003, 07:11 AM
Hello,

I am trying to calculate the number of days within a certain period on a report.

However, the number of days must not count Saturdays or Sundays.

I can calulate the number of days using: [EndDate]-[StartDate]. But how can I take Saturdays and Sundays out of this calucation?

How might I start to work this one out?

Thanks!

dj_T

Mile-O
10-28-2003, 07:49 AM
This might be of some help: click here (http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=56475)

Tay
10-28-2003, 07:50 AM
Check out the DateDiff function by doing a search on here.
In one of my db's I have a module with the following code which I can then call in any form or report - saves time if you need it in a lot of reports. HTH

Public Function GetWorkingDays(StartDate As Date, EndDate As Date) As Integer

Dim Days As Integer
Dim WorkingDays As Integer
Days = datediff("d", StartDate, EndDate)
WorkingDays = Days - datediff("ww", StartDate, EndDate, 1) - datediff("ww", StartDate, EndDate, 7) + 1

GetWorkingDays = WorkingDays

End Function

Tay
10-28-2003, 08:02 AM
Seeing that Mile-O's code encompasses bank holidays, ignore mine.
ps, thanks Mile - looks very useful.