Skip 15 business days from now to select a new date

Dave_p
Giga Guru

Hi,

 

I have a scenario where I should not allowed to select 15 business days from today. I found the code from the documentation, I updated it a little and it looks like I am getting the output as 2 months. Kindly help.

 

var startDate = new GlideDateTime();
gs.addInfoMessage(startDate);
var days = 15;
var dur = new GlideDuration(60 * 60 * 24 * 1000 * days);
var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828');
var end = schedule.add(startDate, dur);
gs.addInfoMessage(end);


output:
Background message, type:info, message: 2025-01-13 17:43:33
Background message, type:info, message: 2025-03-12 16:43:33

 

Regards

Suman P.

3 REPLIES 3

AshishKM
Kilo Patron
Kilo Patron

Hi @Dave_p ,

 

Its showing the end date based on applied schedule with duration

the end date calculation is excluding the non-business hours as per applied schedule.

 

-Thanks,

AshishKM

 

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Ankur Bawiskar
Tera Patron
Tera Patron

@Dave_p 

I already shared solution here in your later question.

Business days Issue 

Please close this thread

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Dave_p 

Hope you are doing good.
Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader