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

@kannan: you are on which version?


I am on Jakarta Patch 5. This could be due to timezones, in my servicenow instance, i am using IST time zone.


Hi Harsh,



where can i able to change time zone .


Hi   Kannan,



i have changed   script using with get




var check= current.u_current_date;


var test = new GlideDateTime(check);


var mn = test.getMonthLocalTime();


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


gs.log('hellosssssss'+quar);


current.u_qua=quar;





but no use still showing in the same way



find_real_file.png


getMonth()Gets the month stored by the GlideDateTime object, expressed in Java Virtual Machine time zone. This method was replaced by the getMonthLocalTime() and getMonthUTC() methods starting with the Eureka release.
getMonthLocalTime()Gets the month stored by the GlideDateTime object, expressed in the current user's time zone. This method is available starting with the Eureka release.



mentioned on wiki..