Solved Business day calculation (1 Viewer)

The Rev

Registered User.
Local time
Today, 06:02
Joined
Jan 15, 2003
Messages
118
Trying to get a date 14 business days in the future. Thought the "weekday" option was my help...

FourteenDay = DateAdd("w", 14, Date)
FourteenDay = Format(FourteenDay, "mmm dd, yyyy")

No dice. Apparently, "weekday" just gives you the day of the week, not a business day. Sigh. I need to get a date 14 business days from the date the script was run. No clue how to do that...

Thankd
 

Minty

AWF VIP
Local time
Today, 11:02
Joined
Jul 26, 2013
Messages
10,371
Have a look at the similar threads links below this thread, at the bottom of the page.

Lots of other examples on here some including optional local holiday calendars.
 

Ranman256

Well-known member
Local time
Today, 06:02
Joined
Apr 9, 2015
Messages
4,337
put these in a module.
usage:
=HowManyWorkDays("1/17/21","1/24/21")


Code:
Public Function HowManyWorkDays(ByVal pvStartDate, ByVal pvEndDate)
On Error Resume Next
    HowManyWorkDays = DateDiff("d", pvStartDate, pvEndDate) + 1 - HowManyWD(pvStartDate, pvEndDate, vbSunday) - HowManyWD(pvStartDate, pvEndDate, vbSaturday)
End Function


Private Function HowManyWD(ByVal pvStartDate, ByVal pvEndDate, WD As Long)
On Error Resume Next
HowManyWD = DateDiff("ww", pvStartDate, pvEndDate, WD) - Int(WD = Weekday(pvStartDate))
End Function
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:02
Joined
Feb 19, 2002
Messages
43,302
To calculate work days accurately, you need a holiday table. Here's a database with many useful date functions.
 

Attachments

  • UsefulDateFunctions20201124b.zip
    300.2 KB · Views: 103

Users who are viewing this thread

Top Bottom