Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

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;