Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Display Quarter number in Quarter field depend on Date

Kishore8
Kilo Guru

My script is not working

var gDate = new GlideDate(current.u_date);

Current.u_quarter= 'Q' + (Math.floor((gDate.getMonth() - 1) / 3) + 1) ;

1 ACCEPTED SOLUTION

Hi,




I have done some modification in script , it is working now


Script :



var gDate = new GlideDate();


gDate.setValue(current.u_date);


current.u_quarter= 'Q' + (Math.floor((gDate.getMonthLocalTime() - 1) / 3) + 1) ;


View solution in original post

6 REPLIES 6

Gowrisankar Sat
Tera Guru

Hi Kishore,



Can you try below code:



var gDate = new GlideDate();


gDate.setValue(current.u_date.getDisplayValue());


current.u_quarter= 'Q' + (Math.floor((gDate.getMonth() - 1) / 3) + 1) ;


Hi Gowrish




not working, please


var test = new GlideDateTime(check);


var mn = test.getMonth();


var quar = Math.ceil(mn/3);


current.u_quarter= 'Q'+quar;


var test = new GlideDateTime(current.u_date);


var mn = test.getMonth();


var quar = Math.ceil(mn/3);


current.u_quarter= 'Q'+quar;