Add 5 days to current date/time gs.nowDateTime()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2018 11:02 PM
Hi All,
I have an requirement to add some days(5) to current date using BR. please help
Regards,
Jyoti

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2018 11:07 PM
You can do
var ed = new GlideDateTime();
ed.addDays(5);
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2018 11:36 PM
(function executeRule(current, previous /*null when async*/) {
if(current.retirement_date == ''){
//var gdt = new GlideDate();
var gdt = new GlideDateTime();
var new_date ='';
//Scheduled retirement is 3 years for Computer hardware
if(current.model_category.getDisplayValue() == 'Computer'){
//timeToAdd = 1096;
new_date = gdt.addDays(1096);
gs.log('test----1'+new_date);
}
//Scheduled retirement is 2 years for Accessory hardware
else if(current.model_category.getDisplayValue() == 'Accessory'){
new_date = gdt.addDays(730);
gs.log('test2---'+new_date);
}
current.retirement_date = new_date;
gs.log('test3----'+current.retirement_date);
}
})(current, previous);
This code is not working as expected

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2018 11:40 PM
Hi,
You can use below function to add years.
gdt.addYears(3);
Thanks,
Ravi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2018 11:54 PM
var gd = new GlideDateTime();
gs.print(gd);
gs.print(gd.addYears(3));
Not working