- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2015 11:50 AM
Hi Everyone,
I have two date & time fields in form, I have used the duration calculator to find the difference between two date&time field values. The result i am getting from calcsheduleduration is in "seconds" but i have set this answer in another "duration" type field like days, hours format. If anyone come across this scenario please guide me to resolve this issue.
Thanks & Appreciation in Advance,
Cheers,
Narendran.D
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2015 07:37 AM
Well, just more math!
if result = 1.753, then you can convert as follows:
var days = parseInt(result,10);
var remainder = result - days;
var dec_hours = remainder * 24;
var hours = parseInt(dec_hours,10);
remainder = dec_hours - hours;
var dec_minutes = remainder * 60;
var minutes = parseInt(dec_minutes,10);
remainder = dec_minutes - minutes;
var dec_seconds = remainder * 60;
var seconds = parseInt(dec_seconds,10);
if (hours < 10) {
hours = '0' + hours.toString();
}
if (minutes < 10) {
minutes = '0' + minutes.toString();
}
if (seconds < 10) {
seconds = '0' + seconds.toString();
}
var new_result = days + ' ' + hours + ':' + minutes + ':' + seconds;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2015 12:30 PM
You can do the math to convert seconds into days, hours, minutes, and seconds, and then call the setDisplayValue() method to set the duration value on your field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2015 11:22 AM
Thanks for your response Geoff.
I have tried with the method you said, I have converted the return value using the below formula but the result i am getting in following format(eg: 1.753, here 1 is day how can i convert the value after decimal?)
var days = work/(3600*24);// work is the variable holding the return value of difference between two dates excluding weekend.
FYI - I need the value in duration format like ( days hrs:min:sec). so can set it directly to duration field.
cheers,
Narendran.D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2015 07:37 AM
Well, just more math!
if result = 1.753, then you can convert as follows:
var days = parseInt(result,10);
var remainder = result - days;
var dec_hours = remainder * 24;
var hours = parseInt(dec_hours,10);
remainder = dec_hours - hours;
var dec_minutes = remainder * 60;
var minutes = parseInt(dec_minutes,10);
remainder = dec_minutes - minutes;
var dec_seconds = remainder * 60;
var seconds = parseInt(dec_seconds,10);
if (hours < 10) {
hours = '0' + hours.toString();
}
if (minutes < 10) {
minutes = '0' + minutes.toString();
}
if (seconds < 10) {
seconds = '0' + seconds.toString();
}
var new_result = days + ' ' + hours + ':' + minutes + ':' + seconds;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2016 03:01 AM
Hi Geoff,
I have tried your script which you mentioned, but i didn't get properly result. May i know what value you are passing as result in your script.
I have one requirement like, i need to calculate total pending time of incident. Through metrics, i got total pending time as milliseconds. I need to converts as duration format like days, hours,minutes and seconds. Could you please help me.