BookmarkSubscribe
Choose Language Hide Translation Bar

Working Days

Hi;

Is there any way to have JMP calculate a formula in working days like the WORKDAY function Excel?  I.E. 3/22/2019 + 1 day would be 3/25/2019 and not 3/23/2019.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions  pmroz
Super User

Re: Working Days

This function will do the trick.  Takes two arguments: a date and the number of days to add (or subtract if negative)

workday = function({one_date, add_days}, {local new_date, dow},

new_date = date increment(one_date, "Day", add_days);
dow = day of week(new_date);
if (dow == 7,	// Saturday
new_date = date increment(new_date, "Day", 2);
,
dow == 1,	// Sunday
new_date = date increment(new_date, "Day", 1);
);
new_date;
);
testdate = informat("3/22/2019", "m/d/y");
workday(testdate, 2);

Output from the log:

25Mar2019  pmroz
Super User

Re: Working Days

This function will do the trick.  Takes two arguments: a date and the number of days to add (or subtract if negative)

workday = function({one_date, add_days}, {local new_date, dow},

new_date = date increment(one_date, "Day", add_days);
dow = day of week(new_date);
if (dow == 7,	// Saturday
new_date = date increment(new_date, "Day", 2);
,
dow == 1,	// Sunday
new_date = date increment(new_date, "Day", 1);
);
new_date;
);
testdate = informat("3/22/2019", "m/d/y");
workday(testdate, 2);

Output from the log:

25Mar2019