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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Function

Status
Not open for further replies.

fabby1

Technical User
Mar 9, 2004
206
GB
Hi

I have an input box for the date and the user then enters the number of days off

Is there a function I can use to add the number of days onto the selected date and exclude weekend and bank holidays

Thanks

Phil
 
Hi

Try searching the forums for WorkingDays and/or MichaelRed, I am sure I remember a post by Michael which gave a function to do this

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi fabby1

I use this function to calculate number of working days. It does not account for Holidays.

Code was posted for me as you're asking for it now.


Function Work_Days(PickedUp As Variant) As Integer
' Note that this function does not account for holidays.
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer


PickedUp = DateValue(PickedUp)
Date() = DateValue(Date)
WholeWeeks = DateDiff("w", PickedUp, Date)
DateCnt = DateAdd("ww", WholeWeeks, PickedUp)
EndDays = 0
Do While DateCnt < Date
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = WholeWeeks * 5 + EndDays
End Function

Testkitt2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top