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

Schedule Job for 3rd Thursday of Every Month

Community Alums
Not applicable

Hi All,

Can someone please advise on the conditional code for running a scheduled job for every 3rd Thursday of the month?

I can find examples online but I am not sure what to change in the code to match my requirement.

Many thanks,

Alex

 

1 ACCEPTED SOLUTION

Elijah Aromola
Mega Sage

Try the following:

var gdt = new GlideDateTime().getDate();
var day = gdt.getDayOfMonth();
var week = gdt.getDayOfWeek();

if(day == 4 && week == 3) {
    //3rd thursday of month
}



View solution in original post

8 REPLIES 8

Elijah Aromola
Mega Sage

Try the following:

var gdt = new GlideDateTime().getDate();
var day = gdt.getDayOfMonth();
var week = gdt.getDayOfWeek();

if(day == 4 && week == 3) {
    //3rd thursday of month
}



Hi,

When the script is added in condition what should be the job run is it daily, on demand?

I tried the same script but when I used daily request is created daily so I tried to use monthly but need to enter the date also.

 

Thanks

Community Alums
Not applicable

Hi there,

My scheduled job is set up like this -

find_real_file.png

 

With the below condition -

//3rd thursday of month
checkDayOfMonth("Thu", "3");

function checkDayOfMonth(day, number){
	
	var result;
	var ordinals = ["", "1", "2", "3", "4", "5"];
	var date = String(new Date());
	var tokens = date.split(" ");
	var floatNumber = ordinals[Math.ceil(tokens[2]/7)];
	var weekDay = tokens[0];
	
	if(floatNumber == number && weekDay == day){
		result = true;
	} else {
		result = false;
	}
		
	return result;
}

 

Hopefully this also works for you!

Thanks,
Alex

Alex,

Thanks for your response I am using the same but for some reason request is created daily please see below snip am I missing something?

 

find_real_file.png