Display Quarter number based on date in Year

chanikya
Kilo Sage

1.Quarter number

2.Current number

Display Quarter number based on date

Ex: Jan   to march   Between related dates Display Quarter -1

April to June Between related dates Display Quarter -3 etc.

Ex:

now Current date: 2017-01-20       week: Quarter-1;

now Current date:2017-05-14           week: Quarter-2

1 ACCEPTED SOLUTION

remove current.update()



var check= current.u_another_open;


var test = new GlideDateTime(check);


var mn = test.getMonth();


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


gs.log('hellosssssss'+quar);


current.u_dateee=quar;




find_real_file.png


View solution in original post

37 REPLIES 37

divya mishra
Tera Guru

Hey Chanikya,



Try using the below script to get the month :


var gdt = new GlideDateTime();


gs.print(gdt.getMonth());



Once you get the values of month you can easily set the Quarter.



post me your feedback


Please Hit ✅Correct, ��Helpful, or ��Like depending on the impact of the response


Have a lovely day ahead




Regards,


Divya Mishra


Kannan Nadar
Tera Guru

Hi,



You can try something like below.



var gdt = new GlideDateTime(current.my_date);


var month = gdt.getMonth();


var quarter = Math.ceil(month/3);


gs.print(quarter);


Hi Kannan,



find_real_file.png



there are showing Quarter value 1.0 it should display only 1



Script is :



var gdt = new GlideDateTime(current.u_current_date);


var month = gdt.getMonth();


current.u_quater = Math.ceil(month/3);


current.update();


What is the field type of quarter?