
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2019 05:58 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2019 06:05 AM
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
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2019 06:05 AM
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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2020 05:43 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2020 01:22 AM
Hi there,
My scheduled job is set up like this -
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2020 08:03 AM