- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 09:31 AM
I have an integer field that stores the value of two dates in seconds.
I would like to convert this integer field (seconds) into a duration field.
For example, result of the two dates is 150000.
How can I convert into a duration field to display as seconds, minutes, hours, days.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 11:41 AM
I tried a client script for this so that as soon as you change the value of the integer it change the duration also:
Integer field is : u_integer_1
Duration field is : u_glide_duration_2
on change of integer Script is something like this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var inputSecondstemp = (g_form.getValue('u_integer_1'));
var inputSeconds = parseInt(inputSecondstemp, 10);
//old school get the variables in place
var secondsInAMinute = 60.0;
var secondsInAnHour = 60.0 * secondsInAMinute;
var secondsInADay = 24.0 * secondsInAnHour;
// extract days
var days = Math.floor(inputSeconds / secondsInADay);
// extract hours
var hourSeconds = inputSeconds % secondsInADay;
var hours = Math.floor(hourSeconds / secondsInAnHour);
// extract minutes
var minuteSeconds = hourSeconds % secondsInAnHour;
var minutes = Math.floor(minuteSeconds / secondsInAMinute);
// extract the remaining seconds
var remainingSeconds = minuteSeconds % secondsInAMinute;
var seconds = Math.ceil(remainingSeconds);
var duration = (days.toString() + " " + hours.toString() + ":" + minutes.toString() + ":" + seconds.toString());
g_form.setValue('u_glide_duration_2', duration);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2018 07:18 AM
It should be written at the dictionary level making the field as calculated value
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
‎08-23-2018 10:42 AM
Thanks
But I wrote in the same place but it didnt work .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 11:41 AM
I tried a client script for this so that as soon as you change the value of the integer it change the duration also:
Integer field is : u_integer_1
Duration field is : u_glide_duration_2
on change of integer Script is something like this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var inputSecondstemp = (g_form.getValue('u_integer_1'));
var inputSeconds = parseInt(inputSecondstemp, 10);
//old school get the variables in place
var secondsInAMinute = 60.0;
var secondsInAnHour = 60.0 * secondsInAMinute;
var secondsInADay = 24.0 * secondsInAnHour;
// extract days
var days = Math.floor(inputSeconds / secondsInADay);
// extract hours
var hourSeconds = inputSeconds % secondsInADay;
var hours = Math.floor(hourSeconds / secondsInAnHour);
// extract minutes
var minuteSeconds = hourSeconds % secondsInAnHour;
var minutes = Math.floor(minuteSeconds / secondsInAMinute);
// extract the remaining seconds
var remainingSeconds = minuteSeconds % secondsInAMinute;
var seconds = Math.ceil(remainingSeconds);
var duration = (days.toString() + " " + hours.toString() + ":" + minutes.toString() + ":" + seconds.toString());
g_form.setValue('u_glide_duration_2', duration);
}