How to set the date from 14 days from current date to 2years

Revathi12
Tera Contributor

Hi Team,

 

We have field called Access where in we need to set the date to 14 days - 2 years from current date. Can you pls help.

2 REPLIES 2

Anurag Tripathi
Mega Patron
Mega Patron

Hi Revathi,

 

Here you go

var gdt = new GlideDateTime();
gdt.addYears(2);
gdt.addDays(-14);
gs.info(gdt.getDisplayValue());
-Anurag

Jitendra Diwak1
Kilo Sage

Hi @Revathi12,

 

You can create the GlideDateTime obj and subtract the 14 days and add the 2 years as below:

 var gdt = new GlideDateTime();
gdt.addYears(2);
gdt.addDays(-14);
gs.print(gdt.getDisplayValue());

 

Please accept my solution if it works for you or thumps up.

 

Thanks

Jitendra

 

Please accept my solution if it works for and thumps up.