Scheduled job should be trigger Every Month second Tuesday

omeo
Tera Contributor

hi.

i neeed to make Scheduled job trigger on every month second tuesday.

but i'm newbie on code. 

 

i think i need to write code range setting second week and will be work

omeo_0-1700547073648.png

help me please

 

1 ACCEPTED SOLUTION

Jack Littlewort
Giga Guru

Hi @omeo 

 

You can use the GlideDateTime class and the getDayOfWeek() function will give you the numerical value of the day (for which Tuesday is 2)  and then getDayOfMonth() to work out if it's the second week (for which anything greater than 7 but smaller than 14 would represent the second week).

 

GlideDateTime | ServiceNow Developers

 

Let me know if you need anything further.

View solution in original post

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @omeo 

 

https://www.servicenow.com/community/developer-forum/create-scheduled-job-to-run-on-2nd-tuesday-of-e...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Jack Littlewort
Giga Guru

Hi @omeo 

 

You can use the GlideDateTime class and the getDayOfWeek() function will give you the numerical value of the day (for which Tuesday is 2)  and then getDayOfMonth() to work out if it's the second week (for which anything greater than 7 but smaller than 14 would represent the second week).

 

GlideDateTime | ServiceNow Developers

 

Let me know if you need anything further.