Sai_Charan_K
Kilo Sage

Hi @Mansi roy ,

I tried the below code in the background script and it seems to work fine. Can you please try checking it.

 

var start=new GlideDateTime("2024-09-20 11:38:19"); //your start date
var end= new GlideDateTime("2024-09-20 11:48:25"); //your end date
var start_mill=start.getNumericValue(); //turning to milliseconds
var end_mill=end.getNumericValue();/turning to milliseconds
var diff=(end_mill-start_mill); //difference in milliseconds
var final_date=new Date(diff).toISOString(); //turning to date once again from milliseconds
gs.print(final_date); //printing the date and time

 

Please find the screenshot attached for the output which I received. 

Please mark my answer "Helpful" and "mark as complete" if you feel that it has helped you in any way.

Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India