Find if Schedule entry is currently active
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 03:27 AM
Hello All,
I'm trying to write a maintenance rule for event management that would add all the servers with a maintenance schedule attached into maintenance from an Alerting prospective.
I have most of the rule in place but I see an issue.
The Date/Time field I get for the schedule start and end time is in the cmn_schedule_span table is of time Schedule Date/Time.
This format seems to be a string like yyyyMMDDTHHmmSSZ e.g. "20240211T070000Z".
I tried creating a new DateTime object using the below code out of this but that doesn't work.
var start_date = new GlideDateTime(schedule_span.start_date_time);
I need to compare this with the current time so I would need a datetime object for both of them. I can use string parsing to separate the above format out but ideally this format should be supported especially when it's in the schedule table.
Is there perhaps a better way to find if a schedule is currently active?
Any help would be great.
Thanks,
Karan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 05:31 AM
Hi Karan,
What is the purpose of checking if the current date time matches the start of a schedule? Are you wanting to check if the current time is within a scheduled period? If so, use the provided GlideSchedule API to do so GlideSchedule | ServiceNow Developers