- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2024 10:43 PM
Hi
I have below requirement.
we have to calculate the difference between updated and created date .
var start_time = new GlideDateTime(grTaskSla.getValue('start_time'));
var end_time = new GlideDateTime(grTaskSla.getValue('end_time'));
var duration = GlideDateTime.subtract(start_time, end_time);
return duration.getDisplayValue();
In duration i am getting duration = updated - created = 3 minutes.
Since this field is integrated with other system. they set length as 3 . It was not accepting.
How to send 3 instead of 3 minutes ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2024 12:48 AM
Hi @Are Kaveri
Try this
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2024 10:48 PM
Hi,
You can do is split 3 from the duration. Use this script for doing the same.
var actualDuration;
actualDuration = duration.split(" "); // duration which has value 3 minutes
var result = actualDuration[0]; // should have 3 as required
Kindly mark it Helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2024 11:35 PM
the solution you provided was working now. But everytime the duration cannot be in minutes ? how to handle this do i need to convert into minutes ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2024 11:50 PM - edited 02-03-2024 11:51 PM
@Hi @Are Kaveri : yes best way is to convert all in minutes, will be easy for other system to receive in same format that is in minutes.
Kindly mark my response Helpful.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2024 12:34 AM
@KalyaniDeshmukh Do you have any sample code for getting minutes in duration??