Workday Calculations

Workday Setup Dialog

Non-programmers often work less than 24 hour, 7 day per week schedules, which gets pretty tricky to calculate dates with. To do this kind of calculation with Napier, you must first set up the workday schedule and workweek calendar from the Options Dialog using the Work Day button.

This shows the following dialog:

The workday start should be set before the end time if the shift starts and ends on the same day. If it ends on the next day after the start, the end time should be before the start time. Shifts longer than 24 hours canít be handled, nor can irregular shift schedules (sorry).

The workday calendar is set up by turning on and off non-workdays. There are two ways to do this, toggling all instances of a weekday, and turning individual days on and off. To change all the Wednesdays for example, tap the button marked w in the week day list. This will turn all the Wednesdays on or off. To turn individual days on and off, just tap the day in the calendar display.

The calendar part can also be used if you want to mark off committed days so they donít get reused. Napier isnít a project scheduling system, but you can do some simple time allocation with it.

If you are working with an overnight shift, the workdays are defined as days a shift starts on. So if the shift is 5PM to 1AM and the workweek is Monday @ 5PM till Saturday @ 1AM, the workdays should be Monday to Friday. Even though there is work performed on Saturday, it isnít marked as a workday, because a shift doesnít start on that day. If Saturday were marked as a workday, it would mean that the workweek was Monday @ 5PM to Sunday @ 1AM.

It turns out that the pattern of days in the year follows a 28 year cycle, so you just set up the workday calendar for 28 consecutive years, then it repeats. Since it is a cycle, you can start with any convenient year, just set it in the Start Year entry. If, for some reason, you donít want to do all 28 years in a cycle, all that is needed is the period you are calculating workdays for.

As discussed more below, the workday schedules can be saved and read back separately from the rest of the state, so you can keep several different schedules in different files and load them as needed.

Accurate Range of Dates for Workday Calculations

Due to the way leap years are calculated, Napier can accurately calculate workdays from Jan 1, 1901 to Dec 31, 2099. It will give you an answer outside those dates, but the workday calendar wonít be accurate. Normal 24 hour day calculations, which donít take account of workday information, work from 1 January 100 ñ 31 December 9999.

Workday Calculation Functions

You can add or subtract workdays to a date, get the number of workdays between two dates, and convert between workdays and 24 hour days. The following examples are all done with an 8 hour day from 9AM to 5PM and only Saturday and Sunday as non workdays, and no holidays defined. All these functions are under the Time function dropdown button.

WDAdd Function ñ Add Workdays to a Date

To add 20 workdays to 9AM Jan 1, 2001, start with this:

The answer is:

WDSub Function ñ Number of workdays between two dates

If you have a given start date and end date, this will give you the number of workdays between them. For example, to get the workdays between Jan 1, 2001 at 9AM and Jan 26, 2001 at Noon, start with

WDSub(#1/1/01 9:00:00#,#1/26/01 12:00:00#)

(Itís easier to see without showing the scrolled command box image)

When evaluated, and converted to a number, this will result in:

Which is 19 and 3/8ths work days, the correct answer.

Fractional Workdays Display ñ Nota Bene

You may however, notice that the info box is showing, 19 days, 9 hours (and a round off error of ‡ millisecs) which is what is displayed in time display mode. This is correct, but a bit inobvious.

Remember that in time display format,Ý a time interval, which is a number of 24 hour days, is converted to days, hours, minutes and seconds. In a 24 hour day, 9 hours is 3/8ths of 1 day, so thatís what is displayed. There is no work hour display function because it would be completely incompatible with all the other time values, and it is all complex enough as it is.

Keep this in mind when working with workdays, you canít enter DHMS(19, 3, 0, 0) when you really mean 19 and 3/8th days. You can enter 19.375 workdays though.

WDTAdd ñ Adding 24 Hour Days to A Date to get Workdays

This function is designed for the case where youíve done a set of calculations which gives you a time interval in normal 24 hour days, but you need to convert it to workdays and add it to a date. For example, you know task A will take 4 work hours, task B 10 work hours, and task C 6 work hours and you have 20 Aís , 6 Bís and 13 Cís.

So start by getting the total time in hours, then divide by 24 to get 24 hour days. This gives you 9.0833 24 hour days.

Now if you start with:

(Notice the use of Val in the argument to reference the previous result)

And tap ENTER, youíll get this:

Which is 9.0833 24 hour days, or with the current workday calendar definition, 27.25 workdays, after Jan 1, 2001 9AM.

T2WD and WD2T Functions ñ Convert Between 24 Hour Days and Workdays

Another way to do the calculation above, is rather than using the WDTAdd function, once youíve got the time in 24 hour days, first convert it to workdays using T2WD (Time to Work Day), then use that answer in the WDAdd function. Youíll get the same answer either way.

If you need to go from workdays to 24 hour days, perhaps on the way to converting to total hours, use the WD2T (Work Day to Time) function.