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

Hi Harsh Vardhan,



if you see the Dates 2019-01-01   displaying Quarter 4


                                                              2019-01-02 displaying Quarter   1



both are in same month January, but it is displaying different , may i know why it is



find_real_file.png






find_real_file.png


i checked at my PDI it's giving me the correct quarter.


can you put the log in your business rule and by the way don't use update() in your business rule. without update() it will set the value in target field.



share your complete business rule..


Hi Harsh Vardhan,




Script is :




var gdt = new GlideDateTime(current.u_current_date);


var month = gdt.getMonth();


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


current.update();






please check is there any thing wrong


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


Hmm.. For some reason, I could see the issue in my instance as well. I replaced getMonth() with getMonthLocalTime(), which helped me solve the issue. Can you try this?