Send Email Periodically 1 Hour for specific Time

Muhammad Arif B
Tera Contributor

Hi, I have requirement to send email by using Scheduled Email Report every 1 hours but specifically between office hour 8AM until 8PM daily. Anyone can provide script or guidance on how to fulfill this requirement?

Thanks

MuhammadArifB_0-1768380817822.png

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron

@Muhammad Arif B 

you can give starting time as 8AM

In condition add this script so that it's sent only between 8am to 8pm every hour

// ServiceNow script to check if current time is between 8 AM and 8 PM
var now = new GlideDateTime();
var timeStr = now.getDisplayValue();  // Format: '2026-01-14 15:30:00'
var parts = timeStr.split(' ')[1].split(':');  // Extract '15:30:00' -> ['15','30','00']
var hour = parseInt(parts[0], 10);

answer = (hour >= 8 && hour < 20);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Muhammad Arif B 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

hi @Ankur Bawiskar 

 

Im implementing your code but change to hour < 13. I will let you know if the code is working (email stop at 1pm)

@Muhammad Arif B 

No worries

but you must have tested it in background script if it gives correct hour etc?

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