In servicenow,how to calculate the business days in each month?

Sr1986
Tera Contributor
 
1 REPLY 1

M Iftikhar
Mega Sage

Hi there,

Calculating business days in ServiceNow can be achieved through a few different methods. Here are the most common and effective approaches you can try:

  1. Use the OOB GlideSchedule API: This is the most powerful method as it automatically considers your company's defined schedule (working hours, holidays, etc.).

    • You can use GlideSchedule to calculate the duration between two dates, excluding non-working days.

    • To get the number of business days in a month, you could calculate the number of working days between the first and last day of that specific month.

  2. Leverage the Business Calendar: This method relies on the predefined business calendars in ServiceNow (cmn_schedule table). You can use the GlideDateTime and calendar APIs to iterate through the days of the month and count only those days that are flagged as "working" days in the calendar.

  3. Create a Simple Script Include: For a reusable solution, you can create a Script Include that contains the logic. This script can use either of the above methods. You can then call this script from Business Rules, Flow Designer, or other places where you need the calculation.

The GlideSchedule method is generally recommended because it is dynamic and respects the official organizational schedule.

 

Hope this helps!

Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it helpful & accept the solution so others can benefit as well.