How to set the date from 14 days from current date to 2years
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 03:26 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 03:35 AM
Hi Revathi,
Here you go
var gdt = new GlideDateTime();
gdt.addYears(2);
gdt.addDays(-14);
gs.info(gdt.getDisplayValue());
-Anurag
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 04:05 AM
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.