Add 1 year to current date in date field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2015 02:57 PM
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?
- 12,653 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2015 07:46 AM
Is there a way for me to make this function to where if the topic is "News" then it will add 30 days, else it will add a year like you did above?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2015 08:53 PM
please try it
i hope, it as your expected.
var d = new GlideDateTime(gs.nowDateTime()); current.topic == "News" ? d.addDays(30) : d.addYearsLocalTime(1); d.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2015 09:30 PM
javascript:gs.yearsAgo(-1) will work

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2017 06:31 AM
Hi Josh,
Set default value for field as javascript:var gdt = new GlideDateTime(gs.nowDateTime());gdt.addYears(1);gdt.getDate();