- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2025 11:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2025 11:53 PM
something like this
1) scheduled job every month, select January
2) use this script in condition field so that job runs only on 2nd saturday
3) then write your script in "Run this script" field
answer = false;
var now = new GlideDateTime();
var year = now.getYearLocalTime();
var janFirst = new GlideDateTime(year + "-01-01 00:00:00");
var dayOfWeek = janFirst.getDayOfWeekLocalTime(); // 1=Monday, 2=Tuesday, ..., 7=Sunday
// Calculate the date of the first Saturday in January
var firstSaturday = 6 - dayOfWeek + 1;
if (firstSaturday <= 0) {
firstSaturday += 7;
}
// Calculate the date of the second Saturday
var secondSaturday = firstSaturday + 7;
// Check if today is the second Saturday of January
if (now.getMonthLocalTime() == 0 && now.getDayOfMonthLocalTime() == secondSaturday) {
answer = true;
}
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
‎02-03-2025 11:53 PM
something like this
1) scheduled job every month, select January
2) use this script in condition field so that job runs only on 2nd saturday
3) then write your script in "Run this script" field
answer = false;
var now = new GlideDateTime();
var year = now.getYearLocalTime();
var janFirst = new GlideDateTime(year + "-01-01 00:00:00");
var dayOfWeek = janFirst.getDayOfWeekLocalTime(); // 1=Monday, 2=Tuesday, ..., 7=Sunday
// Calculate the date of the first Saturday in January
var firstSaturday = 6 - dayOfWeek + 1;
if (firstSaturday <= 0) {
firstSaturday += 7;
}
// Calculate the date of the second Saturday
var secondSaturday = firstSaturday + 7;
// Check if today is the second Saturday of January
if (now.getMonthLocalTime() == 0 && now.getDayOfMonthLocalTime() == secondSaturday) {
answer = true;
}
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
‎02-05-2025 09:20 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