Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
How to schedule a script/report Mondays to Friday every hour between 11am and 5pm - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • How to schedule a script/report Mondays to Friday every hour between 11am and 5pm
KB0786496

How to schedule a script/report Mondays to Friday every hour between 11am and 5pm


1849 Views Last updated : Jan 3, 2025 public Copy Permalink
KB Summary by Now Assist

Summary

Out of the box, you can schedule your script executing Periodically at a defined repeat interval. But when you have a requirement like scheduling a script/report Mondays to Friday every hour between 11am and 5pm then it is little tricky. We can achieve this requirement by adding a conditional script.

Please use below script as a reference and modify this further as per your business need.

Release

Applicable to all releases

Instructions

doIt();

function doIt() {
var gdt = new GlideDateTime(); //setup date time object
var hourInUTC = gdt.getTime().getHourOfDayUTC(); //Gets Hours
var dayOfWeek = gdt.getDayOfWeekUTC();

var startingHour = 11; //Adjust to correct UTC offset
var endingHour = 17; //Adjust to correct UTC offset

if (dayOfWeek < 6) {
if (hourInUTC >= startingHour && hourInUTC < endingHour) {
gs.log('Condition True: ' + gdt, 'doIt');
return true;
} else {
gs.log('Condition False: ' + gdt, 'doIt');
return false;
}
}
}

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.