Schedule job on 2nd sunday of a month

Community Alums
Not applicable

Hi All,

I would like to run a schedule job on 2nd Sunday of a month.Can we directly get the week through any function?

Regards,

kirti

8 REPLIES 8

Well, then you can set the schedule of the scheduled Job to weekly to run every Tuesday. Then you check on the condition field and add something were it calculates the difference between the current data and gs.beginningOfThisMonth(). If it below seven, then you have not get yet to the second tuesday, if it's above 15, then you're ahead of the second tuesday.



I hope it helps!



Thanks,


Berny


prajaktanaik
Giga Expert

Hi Kirti,



Did you get the solution for this? I have the same requirement where I need to schedule a job to run on 2nd Monday of every month.



Thanks,


Prajakta


Rajender1
Mega Sage

Hi kirti,


i have done with below script and it worked perfectly for me.


function checksecondsunday() {


var gdt = new GlideDateTime();


var day = gdt.getDayOfWeek();



var result = true;


  if (day == 0 && (gdt.getDate() >7 && gdt.getDate()<=14)){


  result = true;


  }


  return result;


}


checksecondsunday();