0

var created = g_form.getValue('sys_created_on'); //First Date/Time field
var  getdate= g_form.getValue('get_date'); //Second Date/Time field
var dttype = 'minute'; //this can be day, hour, minute, second. By default it will return seconds.

var ajax = new GlideAjax('ClientDateTimeUtils');
ajax.addParam('sysparm_name','getDateTimeDiff');
ajax.addParam('sysparm_fdt', created);
ajax.addParam('sysparm_sdt', getdate);
ajax.addParam('sysparm_difftype', dttype);
ajax.getXMLAnswer(dateDifference);

function dateDifference(answer){
alert(answer);
}

Calculate date/time diff in seconds, minutes, hours, or days different two glide date/time fields
admin Changed status to publish December 26, 2023