how to calculate no: of mondays / tuesdays / wednesdays ... etc in a month

soumyadaggula
Tera Contributor

soumyadaggula_0-1669455465800.png

Hello team , 

I have a month field with drop down of months with values 1 - 12 , when I select a month ( ex :Jan ) and select 1st Monday , it should give me a count of how many Mondays are there in the selected month , and so on for Tuesday / wednesday .... 

I tried this script , but it does not work .

var dt = "audit_month";
var gdt = new GlideDateTime(dt);
var day = gdt.getDayOfWeek();
var days = gdt.getDayOfMonthLocalTime();

if ((day == 1 || day==2 || day==3) && ((days >=1 && days <=7))) {
g_form.setValue("u_days", days);

 

6 REPLIES 6

Give me your requirement 


Thanks and Regards,

Saurabh Gupta

My requirement is when I select Monday , I should get the numbers Mondays in the current month , and so on for Tuesdays , wednesday.......... Saturdays . 
I posted my question here and got directed to your solution 
Re: How to find number of Mondays , Tuesdays.....S... - ServiceNow Community