
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2018 11:41 AM
I'm currently using the subtract function for two GlideDateTime values (since scoped apps will not allow you to use datediff). The problem is that I can set the date to a week ago or a month ago and the value it returns everytime is two hour difference when asking for the display of the result. Has anyone else experienced this issue in a scoped application?
Here is an example of values and what is returned.
Today's date:2018-05-22 18:30:58
Exp Date:2018-05-15 20:59:55
Diff (using subtract):1969-12-25 02:28:56
diff display (using getDisplayValueInternal):20:28:56
I've tried to take the value returned from the subtract and use javascript to get the difference between that and the beginning of time, but .getTime() is not accepted. Any assistance is greatly appreciated.
Thanks,
Britt
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2018 02:45 PM
it works ok for me. here is a sample script that i tested in scope:
var sdt = new GlideDateTime();
sdt.setValue('2018-01-01 12:30:00');
var edt = new GlideDateTime();
edt.setValue('2018-01-01 20:00:00');
var diff = GlideDateTime.subtract(sdt, edt);
// get the number of ms between the 2 dates
var dur = diff.getNumericValue();
gs.info(dur);
// get the number of hours
var hrs = dur / 1000 / 60 / 60;
gs.info(hrs);
// output the diff display value
gs.info(diff.getDisplayValue());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2018 02:45 PM
it works ok for me. here is a sample script that i tested in scope:
var sdt = new GlideDateTime();
sdt.setValue('2018-01-01 12:30:00');
var edt = new GlideDateTime();
edt.setValue('2018-01-01 20:00:00');
var diff = GlideDateTime.subtract(sdt, edt);
// get the number of ms between the 2 dates
var dur = diff.getNumericValue();
gs.info(dur);
// get the number of hours
var hrs = dur / 1000 / 60 / 60;
gs.info(hrs);
// output the diff display value
gs.info(diff.getDisplayValue());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2018 07:00 AM
Thanks for the help! 🙂
The getNumericValue did the trick. The other method I was using was giving me weird results.