DateDiff

C

CJ

I am trying to work out the number of working days between two dates.
I am using the DateDiff function, but this appears to count weekends.
Giving me fault results.
Thurs 12th to Tue 17th, should return 3, but returns 5.

Is there an interval for this, or should I use a different function.

I know in Excel its NETWORKDAYS.

Thanks
 
J

John W. Vinson

I am trying to work out the number of working days between two dates.
I am using the DateDiff function, but this appears to count weekends.
Giving me fault results.
Thurs 12th to Tue 17th, should return 3, but returns 5.

Is there an interval for this, or should I use a different function.

I know in Excel its NETWORKDAYS.

Thanks

There's nothing builtin in Access to do this (a bit odd, but that's how MS
programmed it!). You will need to add some custom code; there's good sample
code at
http://www.mvps.org/access/datetime/date0012.htm

As noted on the webpage, you'll probably want to create a table of the olidays
that your organization observes.
 
V

vanderghast

If there is a large interval of dates between the two dates, and if you are
only interested in removing Sunday and Saturdays, you can do the following:

DateDiff( "w" , startingDate, endingDate) ' returning the number of
days, including Sunday and Saturday
- DateDiff("ww", startingDate-1, endingDate, vbSunday ) ' the number
of Sundays
- DateDiff("ww", startingDate-1, endingDate, vbSaturday) ' the number
of Saturdays.


You would have to manually remove any non working day falling / reported on
a weekday.

I assumed your starting date is later than the 31st December 1899. If not,
you will have to use DateAdd('w", -1, startingDate) rather than
startingDate-1.


Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top