
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2017 08:55 AM
I want a field to display the difference between two times in minutes.
Eg: Business Duration = 136
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2017 11:00 AM
Hello Santhana
Please try below. g_form doesnot work server side
(function calculatedFieldValue(current) {
var dateString1 = new GlideDateTime(current.begin); //make sure variable name is begin
var dateString2 = new GlideDateTime(current.end); // make sure variable name is end
var diffSeconds = gs.dateDiff(dateString1, dateString2, true);
diffMins = diffSeconds/60;
return Math.round(diffMins); // return the calculated value
})(current);
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
‎12-27-2017 09:15 AM
Hello Rajhan
Can we try something like this:
var dateString1 = '2017-12-26 07:39:52';
var dateString2 = '2017-12-26 09:55:22';
var diffSeconds = gs.dateDiff(dateString1, dateString2, true);
diffSeconds = diffSeconds/60;
gs.print(Math.round(diffSeconds));
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
‎12-27-2017 10:36 AM
I created an Integer field, Business Downtime and added the below script in the Calculated Value. - Any suggestions?
(function calculatedFieldValue(current) {
// Add your code here
var dateString1 = g_form.getValue('begin');
var dateString2 = g_form.getValue('end');
var diffSeconds = gs.dateDiff(dateString1, dateString2, true);
diffSeconds = diffSeconds/60;
gs.print(Math.round(diffSeconds));
return ''; // return the calculated value
// })(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2017 11:00 AM
Hello Santhana
Please try below. g_form doesnot work server side
(function calculatedFieldValue(current) {
var dateString1 = new GlideDateTime(current.begin); //make sure variable name is begin
var dateString2 = new GlideDateTime(current.end); // make sure variable name is end
var diffSeconds = gs.dateDiff(dateString1, dateString2, true);
diffMins = diffSeconds/60;
return Math.round(diffMins); // return the calculated value
})(current);
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
‎12-27-2017 11:12 AM
Got it. Awesome.
Thanks for the much help.
I also got another task. Based on the value on this number and values from multiple fields, i need to calculation and get the numbers populated in a separate field.