The CreatorCon Call for Content is officially open! Get started here.

To check if today (current date) is the first Saturday of the month.

Chandler2
Tera Guru

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!

7 REPLIES 7

Sagar Pagar
Tera Patron

Please check this old thread for solution.

Scheduled Job - First Saturday of each month

 

Thanks!

Sagar Pagar

The world works with ServiceNow

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

in the script or the condition field you can check like this

var gdt = new GlideDateTime();
var dayOfWeek = gdt.getDayOfWeekLocalTime();
var dayOfMonth = gdt.getDayOfMonthLocalTime();

if(dayOfWeek == 6 && dayOfMonth < 7 ){
	gs.info("First Saturday");
}

regards
Ankur

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

Hi Ankur,

Thanks for the response but I am wondering how to test this?

If I change my system date to a Saturday, will it show True?

Hi,

real time testing can only happen when it's first saturday or the month

try to give some hard-coded date and check if it returns true or false

1) give 1st saturday of May and verify

regards
Ankur

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