Skip to content

Calculate next workday

Visual Foxpro code to calculate the next working day. Taking into account that our working week is from Monday (1) to Friday (5).

We use the built in DOW() Function (short for Day Of Week). Be careful to include the second parameter, being the specifier at which weekday your week starts. If you omit this, Foxpro tries to determine this from the Foxpro region settings which may not be what you expected. Better is to make the second parameter value 2: defining that your week starts on Monday.

The function should be able to cope with any given date, allways delivering the next working day.

This is the function (Dutch var names):

ldVandaag = DATE()
ldVolgendeWerkdag = ldVandaag + IIF(DOW(ldVandaag,2)>4,8-DOW(ldVandaag,2),1)

Or the English equivalent:

ldToday = DATE()
ldNextWorkDay = ldToday + IIF(DOW(ldToday,2)>4,8-DOW(ldToday,2),1)

Leave a Reply

Your email address will not be published. Required fields are marked *