How to get a fiscal year from the date field .

ragz
Tera Expert

In ServiceCatalog Date variable I am getting current Year (2019 )using the below default value

javascript: var gdt = new GlideDateTime(gs.nowDateTime());gdt.getYear();

But I need to get 2020 as from ( ex May) a month fiscal year starts .

How to achieve that ?

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Try this code.

var gdt = new GlideDateTime(gs.nowDateTime());
if(gdt.getMonth()+1 <=3)
return gdt.getYear();
else
return gdt.getYear()+1;

Mark the comment as a correct answer and also helpful once worked.

View solution in original post

3 REPLIES 3

asifnoor
Kilo Patron

Try this code.

var gdt = new GlideDateTime(gs.nowDateTime());
if(gdt.getMonth()+1 <=3)
return gdt.getYear();
else
return gdt.getYear()+1;

Mark the comment as a correct answer and also helpful once worked.

working fine but giving 2020.0

 

How to get rid of .0 ?

goldenjc97
Tera Contributor

@ragz  - did you figure this out? Can you drop the javascript&colon; value if so? Thanks