The Zurich release has arrived! Interested in new features and functionalities? Click here for more

need to get difference between create and closed dates in days and hours.

anshul_jain25
Kilo Guru

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.

1 ACCEPTED SOLUTION

Shishir Srivast
Mega Sage

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


View solution in original post

6 REPLIES 6

samiul1
Tera Expert

This is the page you should have a look : Setting the Duration Field Value - ServiceNow Wiki


Shishir Srivast
Mega Sage

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


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;


lakshminarayan4
ServiceNow Employee
ServiceNow Employee

hi ,


you can use this function . gs.calDatediff . Please find the doc here.



GlideSystem Date and Time Functions - ServiceNow Wiki



Thanks


- YLN