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-10-2017 06:12 PM
HI Rouf
You are missing object for the due date.
OBJECT.due_date.getDisplayValue()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2017 06:44 PM
if dueDate is a GlideDateTime, you just do the following:
GlideDateTime.subtract(due_date, gs.nowDateTime());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2017 07:06 PM
Hello Mohammed
This thread will help you
How to set Calculated Value for Duration (or any other date/time) field
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2017 09:47 PM
Try if this works:
Following this syntax:
<duration_field> = GlideDateTime.subtract(new GlideDateTime(current.due_date),gs.nowDateTime());