Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
PNash
Level II

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
Highlighted
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

View solution in original post

1 REPLY 1
Highlighted
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

View solution in original post

Article Labels

    There are no labels assigned to this post.