Add 1 year to current date in date field

codedude
Mega Expert

I have a date field where I am currently setting the defualt value to todays date using javascript:now();. I am unable to figure out how to set the defualt value to todays date + 1 year....  

Can someone please help me with this?

8 REPLIES 8

Ravish Shetty
Tera Guru

Use this:



javascript:var gdt = new GlideDateTime(gs.nowDateTime());gdt.addYears(1);gdt.getDate();


Additional: we should use addYearsLocalTime instead of addYears since Eureka


I have a created a feild and trying to add 1year to the current date.



Still not populating



function execute() {  


      var newDate = new GlideDateTime();  


newDate.addyears(1);


current.u_annual_review = newDate.getDate();


}  


HungMiju
Mega Expert

you can create a "Dynamic Filter Options"


for date field
use: var d = new GlideDateTime(gs.nowDateTime()); d.addYearsLocalTime(1); d.getDisplayValue();



add1year.png