- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 08:11 AM
In my NON scoped app i used gs.dateDiff to get difference between two dates and it worked perfectly.
I am now in a scoped app and cannot use gs.dateDiff.
says to use GlideDateTime.subtract(d1, d2);
that returns a duration object of the form: 2 Days 23 Hours
How do i convert the duration object to seconds?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 08:47 AM
Try this:
var t = new GlideDateTime();
var f = new GlideDateTime('2019-04-08 16:43:33');
var dur = GlideDateTime.subtract(t, f);
var duration = dur.getNumericValue();
var durationSeconds = (duration/1000);
gs.info(t);
gs.info(dur.getDisplayValue());
gs.info(durationSeconds );
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 08:26 AM
This post might give you an idea
https://community.servicenow.com/community?id=community_question&sys_id=3e52d761db101fc01dcaf3231f96199c
Please mark helpful/correct if the content solved your issue
Thanks,
Harshinya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 08:34 AM
Take a look at this
https://community.servicenow.com/community?id=community_question&sys_id=11010fa5db98dbc01dcaf3231f96194f
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 08:38 AM
i have looked at posts and documentation and it is still not clear ...
I need the actual script ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2019 08:47 AM
Try this:
var t = new GlideDateTime();
var f = new GlideDateTime('2019-04-08 16:43:33');
var dur = GlideDateTime.subtract(t, f);
var duration = dur.getNumericValue();
var durationSeconds = (duration/1000);
gs.info(t);
gs.info(dur.getDisplayValue());
gs.info(durationSeconds );
Please mark my response as correct and helpful if it helped solved your question.
-Thanks