working days formula

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Working days formula

Working days formula

resolvedResolved · High Priority · Version 2003

James has attended:
Access VBA course

Working days formula

calculating working days diff rather than daysdiff.
steve asked to post reminder

RE: working days formula

Hi James

Thanks for the post, Stephen is available tomorrow and will review your post.

regards

Jacob

RE: working days formula

Still no reply to my question

Unless I am missing it?

Edited on Mon 26 Oct 2009, 15:26

RE: working days formula

Hi James

Apologies, I was sure I had answered this but I can find no reference to it, so I can only imagine that there was some glitch when I tried to post.

The following function will count the working days between two dates, by excluding Saturdays and Sundays.

Function WorkDays(dteStart As Date, dteFinish As Date) As Integer

Dim dteDateCount As Date
Dim intCount As Integer

For dteDateCount = dteStart To dteFinish

If Weekday(dteDateCount) <> 7 Then 'excludes saturdays

If Weekday(dteDateCount) <> 1 Then 'excludes sundays

intCount = intCount + 1

End If

End If

Next dteDateCount

WorkDays = intCount

End Function


It uses the vb function weekdays to exclude dates on a saturday (day7) or a sunday(day1).

The following procedure calls this function and places two dates for the start and finish arguments

 Sub Caller()

MsgBox WorkDays(#10/19/2009#, #10/28/2009#)


End sub


Hope this helps

Regards

Stephen

Mon 2 Nov 2009: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Duplicating an Entry

To duplicate the entry press CTRL+' (apostrophe)this will copy the contents of the previous entry in the same field.
(Table view, line above) note this also works in Excel.

View all Access hints and tips


Server loaded in 0.05 secs.