To check if today (current date) is the first Saturday of the month.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 01:58 AM
I have a scheduled job set to run daily but I need to check in condition script that if today is first Saturday of the current month? Then only run the scheduled job.
Can someone please share the code needs to be used for that in the condition area?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 10:14 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2023 10:44 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 09:46 PM
Hi Chandler,
May 7th is the first Saturday on this month. I've changed to script to "dayOfMonth <= 7" from "dayOfMonth < 7" to include 7th.
var today = '2022-05-07 00:00:10';
var gdt = new GlideDateTime();
gdt.setDisplayValue(today);
var dayOfWeek = gdt.getDayOfWeekLocalTime();
var dayOfMonth = gdt.getDayOfMonthLocalTime();
if(dayOfWeek == 6 && dayOfMonth <= 7 ){
gs.info(gdt.getDisplayValue() + " is first Saturday");
} else {
gs.info(gdt.getDisplayValue() + ' is not first Saturday');
}
Execution result:
Test by changing 'today' value.
case 1: today = '2022-05-07 00:00:00'
*** Script: 2022-05-07 00:00:10 is first Saturday
case 2: today = '2022-06-03 00:00:00
*** Script: 2022-06-03 00:00:00 is not first Saturday