Difference between two dates are showing in the Negative and in the form of Seconds

Ashok32
Tera Contributor

Hi All,

 

While we are calculating the difference betrween two date Field values. I ts showing the difference in the form of seconds and negative values are generating at the time of report generation. In the list level, Its showing as

 

Ashok32_1-1681297392076.png

 

Whereas in report level the difference shows like

-86817

Can anyone help me to resolve this.

 

Thanks in advance

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Ashok32 

can you share what script are you using for calculating?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

 var start = new GlideDateTime();
var end = new GlideDateTime(current.end_date);
var dur = new GlideDuration();
dur = GlideDateTime.subtract(start, end).toString();
current.setValue('u_diff', dur);

 

@Ashok32 

script looks good.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ashok32
Tera Contributor

Hi @Ankur Bawiskar ,

 

In the reports its shows duration in seconds and that too its a negative value. How can we convert that seconds to  minutes or days in the report level.