Duration Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 06:56 AM
Hello Community,
When I enter "24 hours" into a Duration field, the system automatically converts it and displays it as "1 day". However, I would like to see it displayed explicitly as "24 hours" instead of being normalized to "1 day".
Is there a way to prevent this automatic conversion or at least display the duration in an "hours" format (e.g., "24 hours") for the users?
Best Regards,
Beyza
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 07:31 AM
Hi @beycos ,
you can use max_unit attribute and set it to hours max_unit=hours
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 05:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 05:27 AM
not possible.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 05:44 AM - edited 05-20-2025 05:45 AM
Hi @beycos ,
not possible
you can create a on load client script for form level
function onLoad() {
var duration = g_form.getValue('duration');
if (!duration) return;
var parts = duration.split(' ');
if (parts.length !== 2) return;
var daypart = parseInt(parts[0]);
var timeParts = parts[1].split(':');
if (timeParts.length !== 3) return;
var hours = parseInt(timeParts[0]);
var minutes = timeParts[1];
var seconds = timeParts[2];
if (daypart <= 2) {
var totalHours = (daypart * 24) + hours;
var paddedHours = totalHours.toString().padStart(2, '0');
var newDuration = paddedHours + ':' + minutes + ':' + seconds;
g_form.setValue('duration', newDuration);
}
}
but in the list view it's still going to show up the day part
update the duration field name with your field name and adjust the script if needed
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya