- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 09:19 AM
Hello,
We have a field with type duration, but am trying to convert it into minutes and pass value on to string field. tried doing
var duration = current.glidefieldonform.getGlideObject().getNumericValue();
gs.log("minutes"+ duration);
var minutes = (duration/1000/60);
gs.log('duration1' + minutes);
current.fieldtobepopulated = minutes.toFixed();
gs.log('duration' + minutes);
it dont work
please help,
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 09:45 AM
Hi Sherice,
Try this code:
var duration = new GlideDateTime(current.glidefieldonform.getValue()); // getting duration and converting to GlideDateTime
duration = duration.getNumericValue()/1000/60; // calculating the total duration in minutes
gs.log('Duration in minutes is: ' + duration);
current.fieldtobepopulated = duration.toString();
Please mark answer as helpful/solved based on impact

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 09:45 AM
Hi Sherice,
Try this code:
var duration = new GlideDateTime(current.glidefieldonform.getValue()); // getting duration and converting to GlideDateTime
duration = duration.getNumericValue()/1000/60; // calculating the total duration in minutes
gs.log('Duration in minutes is: ' + duration);
current.fieldtobepopulated = duration.toString();
Please mark answer as helpful/solved based on impact

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 09:53 AM
Use below code
var i = new GlideRecord('incident');
i.addQuery('sys_id',"41c01200d7002100b81145a3ce610398");
i.query();
if(i.next()){
var h = i.business_duration.dateNumericValue()/1000;
var hr = h/3600;
var m = hr*60;
gs.info("Minutes value " + m);
}
Regards,
Sachin