How to add two years to a dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 03:47 AM
Hi,
I need to update date field as tomorrow + 2years.
if I am submitting the form on 2 May 2022, it should display tomorrow + two years. after date is added field should be readonly
I am using below code in client script
gdt = new GlideDateTime().getDisplayValue();
gdt.addYears(2);
gdt.adddays(1);
gdt.getDate();
I am receiving errors in console
My scope is Human Resource

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 03:49 AM
Hey,
var gdt = new GlideDateTime();
gdt.addYears(2);
gs.info(gdt);
If you want to add 1 day as well, add this line as 3rd line in the code:
gdt.addDays(1);
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 03:52 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 03:55 AM
You should have told you are writing a client script, this only works in server side.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 03:57 AM
I have pasted in my question, I am using client script