GlideDateTime.subtract doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2017 05:58 PM
I used the following commands on default value to calculate the number of days subtracting current date to due date but didn't work. Any comment or advise is greatly appreciated.
javascript:calendar_duration = GlideDateTime.subtract(due_date.getDisplayValue(), gs.nowDateTime());
Following this syntax:
<duration_field> = GlideDateTime.subtract(<start_field>.getDisplayValue(),gs.nowDateTime());
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2017 12:26 AM
Hi Mohammed Rouf,
Please correct your script and try running something like this
var sgd = new GlideDate();
sgd.setValue('2018-03-21');
var tdy = new GlideDate();
tdy.setValue('2017-12-12');
duration = GlideDate.subtract(tdy,sgd);
gs.info(duration.getDisplayValue());
Hope this helps.... PLEASE MARK my answer as HELPFUL OR CORRECT if it served your purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2017 10:49 AM
Yes, it subtracts the hardcoded date successfully but I need to make it read the dates from fields & then subtract.