- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 09:00 PM
hi
i want to create a new field where i want to display difference of create and close date once request gets closed.
and i want difference in days and hours.
how can i achieve this.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 09:11 PM
Please use the datediff function to calculate the difference between the date with boolean value as false.
dateDiff(String, String, boolean):
- boolean bnumericValue - true to return difference in number of seconds as a string, false to return difference in the format ddd hh:mm:ss.
GlideSystem Date and Time Functions - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 09:09 PM
This is the page you should have a look : Setting the Duration Field Value - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 09:11 PM
Please use the datediff function to calculate the difference between the date with boolean value as false.
dateDiff(String, String, boolean):
- boolean bnumericValue - true to return difference in number of seconds as a string, false to return difference in the format ddd hh:mm:ss.
GlideSystem Date and Time Functions - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 09:20 PM
please check if after update business rule helps.
var closeddt = new GlideDateTime(current.closed_date.toString());
var createddt = new GlideDateTime(current.created_date.toString());
var diff = gs.dateDiff(createddt.getDisplayValue(), closeddt.getDisplayValue(), false);
current.difference_field_name = diff;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2017 09:12 PM
hi ,
you can use this function . gs.calDatediff . Please find the doc here.
GlideSystem Date and Time Functions - ServiceNow Wiki
Thanks
- YLN