Skip to content

Conversation

@Soumyadeep10
Copy link
Contributor

@Soumyadeep10 Soumyadeep10 commented Oct 8, 2025

I have created an ServiceNow action which is described as follows:

Name: Calculate Business Days Duration

What it does :

  1. This action takes Start date, end date and the chosen Business Schedule as input and calculates the true elapsed time between a start date/time and end date/time.
  2. It uses a defined Business Schedule (like 8-5 weekdays) and ignores nights, weekends.
  3. It gives the result as a string (eg: 2 day 12 hours).
  4. It also carries a Start date and End date validation where if the Start date is after End date, it throws error!

Let's explain with an example:
Inputs -

  • Start date: 9.10.25 21:00:00
  • End date: 16.10.25 21:00:00
  • Schedule: 8-5weekdays [which means 8:00AM to 5:00PM, Mon-Fri, 45 hours per week]

Output with explanation-
The total calendar time between the times chosen is exactly 7 days. The action ignores all times except the scheduled business hours.

  • Oct 9 (Start): The start time is 9:00 pm which is outside the schedule so, the action waits for next day.
  • Oct 10 (Friday): Counts 9 hours
  • Oct 11-12(Weekend): Counts 0 hrs.
  • Oct 13-17 (Mon-Fri): Counts 9 hours each day * 5 days = 45 hours.
  • Total is 9 + 45 = 54 hours

Result = 2 day 6 hours

[Note: The result may vary based on different timezone settings on instance]

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

Valid PR for ActionPack

Thank you for your contribution. This PR complies with the CONTRIBUTING.md.
A maintainer will review this shortly. In the meantime, Happy Hacking!

@rohi-v rohi-v self-assigned this Oct 8, 2025
Copy link
Contributor

@rohi-v rohi-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Soumyadeep10
Thank you for your contribution
Positive scenarios are working well, can you also add additional checks for

  • 'If start date is after end date' then return a message
  • Add conditions for 'Error Evaluation' if step1 fails.
  • Add your logic in try/catch statements.

@Soumyadeep10
Copy link
Contributor Author

@rohi-v I have made the changes requested for #119 .

@Soumyadeep10 Soumyadeep10 requested a review from rohi-v October 9, 2025 03:45
@rohi-v
Copy link
Contributor

rohi-v commented Oct 9, 2025

Thank you for making the changes,Will review.

@rohi-v
Copy link
Contributor

rohi-v commented Oct 9, 2025

Looking good, Thank You for your contribution.

@rohi-v rohi-v merged commit d2886c1 into ServiceNowDevProgram:main Oct 9, 2025
@Soumyadeep10
Copy link
Contributor Author

Thanks a lot @rohi-v !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants