one hour time difference in getdisplayvalue and getvalue

Shahebaz2
Kilo Contributor

Hello Experts,

I am experiencing very strange behavior while calculating the time difference between two dates.

I am also using the schedule to exclude weekends from time calculation.

When I fetch the values of GlideDateTime objects using getDisplayvalue and subtracting those values is one hour more than the difference between those values which are fetched by using getvalue method of glidedatetime.

For example

date1 = 2020-12-02 11:22:06 and date2 = 2020-12-21 00:00:00

time difference between two dates when values fetch using getDisplayvalue is 12Days 12:37:54(HH:MM: SS)

time difference between two dates when values fetch using getvalue is 12Days 13:37:54(HH:MM: SS)

Please suggest your valuable comment on this.

7 REPLIES 7

can you paste the full script ? 

sample code:

 

var start = new GlideDateTime("2016-08-28 09:00:00");


var end = new GlideDateTime("2016-08-31 08:10:00");


gs.print(gs.dateDiff(start.getDisplayValueInternal(), end.getDisplayValueInternal(), true)); // returns the number of seconds as String

Ankur Bawiskar
Tera Patron
Tera Patron

@Shahebaz 

As suggested please share complete script

Regards
Ankur

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