workday/workweek calculation

Recommended Posts

I searched on here but did not find what I wanted to do.

I have a countdown timer that counts down the days (calendar) to a specific date. I have a project due that date but need to calculate using only workdays and/or work weeks. That way I know how much time is really needed to work on a project.

Any help on the calculation would be great.

E

Share on other sites

http://www.wikihow.com/Calculate-the-Day-of-the-Week

Share on other sites

I searched on here but did not find what I wanted to do.

I have a countdown timer that counts down the days (calendar) to a specific date. I have a project due that date but need to calculate using only workdays and/or work weeks. That way I know how much time is really needed to work on a project.

Any help on the calculation would be great.

E

It's ugly but it works. It calculates workdays assuming that a workday is Monday - Friday. Dates must be entered in the format YYYY/MM/DD

Try it and let me know if this is what you were looking for...

```#include <Date.au3>

\$example = HowManyWorkDays("2009/10/15", "2009/10/21")

MsgBox(0, "Number of Weekdays", "There are " & \$example & " weekdays between the given dates")

Func HowManyWorkDays(\$sStartDate, \$sEndDate)
Dim \$MyDate
Dim \$MyTime

\$myStartDate = \$sStartDate
\$myEndDate = \$sEndDate
\$countWeekDay = 0

\$CountDays = _DateDiff("d", \$myStartDate, \$myEndDate)

For \$inc = 0 To \$CountDays
_DateTimeSplit(\$TempDate, \$MyDate, \$MyTime)
\$FileYear = \$MyDate[1]
If \$MyDate[2] < 10 Then
\$FileMonth = "0" & \$MyDate[2]
Else
\$FileMonth = \$MyDate[2]
EndIf
If \$MyDate[3] < 10 Then
\$FileDay = "0" & \$MyDate[3]
Else
\$FileDay = \$MyDate[3]
EndIf

;Returns Day of the Week Range is 1 to 7 where 1=Sunday
\$iWeekday = _DateToDayOfWeek(\$FileYear, \$FileMonth, \$FileDay)
If \$iWeekday > 1 And \$iWeekday < 7 Then
\$countWeekDay = \$countWeekDay + 1
EndIf
Next

Return \$countWeekDay
EndFunc   ;==>HowManyWorkDays```

Create an account

Register a new account