Set a default date as 5 business days opposed to 5 days.

Marc43
Kilo Expert

I currently have a date variable with a default value set for 5 days past the day the request is submitted. However, we would like to set this as 5 business days to not include weekends. Is this possible? Below is the script we are currently using for the default value:

javascript: new GlideDateTime(gs.daysAgo(-5)).getDisplayValue();

1 ACCEPTED SOLUTION

//Try this as the default value

 

javascript: var d5 = '';
var gdt = new GlideDateTime();
var d = 5;
if (gdt.getDayOfWeek() == 6) {
daysout = daysout + 2;
}
if (gdt.getDayOfWeek() == 7) {
d = d + 1;
}
d = d * -1;
d5 = new GlideDateTime(gs.daysAgo(d)).getDisplayValue();
d5;

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

View solution in original post

5 REPLIES 5

//Try this as the default value

 

javascript: var d5 = '';
var gdt = new GlideDateTime();
var d = 5;
if (gdt.getDayOfWeek() == 6) {
daysout = daysout + 2;
}
if (gdt.getDayOfWeek() == 7) {
d = d + 1;
}
d = d * -1;
d5 = new GlideDateTime(gs.daysAgo(d)).getDisplayValue();
d5;

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022