Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Add an year to a current date in client script

Khanna Ji
Tera Guru

Hi Team,

I have taken the below script from the thread but it's not giving desired results 

client script to add 1 year to current date - Now Platform - Question - ServiceNow Community

@Ankur Bawiskar 

var todayDate = new Date(new Date().setFullYear(new Date().getFullYear() + 1));
g_form.setValue('valid_to', todayDate.toISOString().slice(0,10));

It is adding the dates as 

But it should be like below

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi,

image is broken

Script should work fine.

I just tried with the debugger.

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Wow...I wasnt sure what that was going to spit out but that worked exactly as intended. Thank you!