addDays is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 07:49 AM
Hi everyone,
I have written the below piece of code.
bit it is not working.
Can anyone please help me on that.
var time=current.u_meeting_date;
var gdt = new GlideDateTime(time);
gs.addInfoMessage(gdt);//this is coming
var timeupdated=gdt.addDays(7);
gs.addInfoMessage(timeupdated);//org.mozilla.javascript.Undefined@4964c7 error
Many thanks in Advance.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 07:58 AM
Try adding the .getDate() as in the WIKI article:
GlideDateTime - ServiceNow Wiki
var gdt = new GlideDateTime("2011-08-31 08:00:00");
gdt.addDays(-1);
gs.print(gdt.getDate());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 08:07 AM
yes i already tried.
that thing is working fine.
but when i tried fetch a date then want to add that is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 08:13 AM
Are you using two different variable for your date/time value? You first set the retrieved value to the "time" variable but then you update the "timeupdated" variable for the updated date/time.
If you're expecting to update the value that your retrieved then you have your calculation in the wrong place. Or perhaps I'm misunderstanding what you're trying to do.
Earl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 08:18 AM
hey,
Please help me to add days.
var time=current.u_meeting_date;//fetching the date and time
var gdt = new GlideDateTime(time);
gs.addInfoMessage(gdt);//this is coming
var timeupdated=gdt.addDays(7);//try to add 7 days
gs.addInfoMessage(timeupdated);//just to display the value which is retriving
Regards,
Swapnali