Discussion Locked

Office 2000 Access / Excel

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Does Access have the ability to calculate the difference between two date fields, bypassing week-ends and optionally holiday dates?
Excel has a function "NetWorkDays" that supports this requirement. Is it possible to use this function in an Accessapplication?

8 replies

by glen_mcleod

It is not possible directly, as the function NetWorkDays() is not available through the Excel.WorkSheetFunction object in Excel version 9 or 10.

Maybe by manipulating cell values through automation, you could get this done, but you can't call thefunction directly through VBA code.

Glen

by glen_mcleod

It is not possible directly, as the function NetWorkDays() is not available through the Excel.WorkSheetFunction object in Excel version 9 or 10.

Maybe by manipulating cell values through automation, you could get this done, but you can't call thefunction directly through VBA code.

Glen

by john_wills

You can give Access the capability. Access has functions for day-of-the-week and you can sum over a date range excluding Saturday and Sunday. If you have a table of holidays, you can arrange your Visual Basic code to subtract a day for each of thoselying in the date range. But be careful not to subtract a day twice, e.g. Christmas falling on a Sunday. I had to do something like this when calculating how good patients were at showing up at the clinic, which was closed at weekends and on holidays. This is what the data selection for one report looked like: SELECT DateList.ThisDate, Format([ThisDate],"dddd") AS DayOfWeek, NullToZero([tempAppearance].[NumberOfClients]) AS NumOfClients, DateList.NumInProgram
FROM DateList LEFT JOIN tempAppearance ON DateList.ThisDate = tempAppearance.SessionDate
WHERE (((DateList.ThisDate) Not In (SELECT HolidayDate FROM Holidays)) AND ((Weekday([ThisDate])) Not In (1,7)));

This discussion is closed to new replies.