Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

After export as Excel time fields are showing seconds but i want to see it in only Hours and Minutes

kranthi2
Tera Expert

Hi,

After export as Excel time fields are showing seconds but i want to see it in only Hours and Minutes.

 

kranthi2_0-1702280472971.png

 

kranthi2_1-1702280490775.png

 

I want to see in the Excel only Hours and minutes.

 

Please help me out on the same.

 

Thanks,

 

 

6 REPLIES 6

Hi Ankur,

Please find the below screenshot:

 

kranthi2_0-1702344210802.png

 

It is working fine is there any possibility to see only Hours and Minutes which means 

HH:MM format only because my customer is requesting the same.

 

Please help me out on this.

 

Thanks, 

 

Hi @kranthi2;

I've just had a similar requirement and solved it with this script:

 

(function calculatedFieldValue(current) {
    // Create a GlideDuration object
    var dur = new GlideDuration();
    
    // Set the value of the GlideDuration object to the duration field
    dur.setValue(current.duration);
    
    // Get the total number of seconds from the duration
    var totalSeconds = dur.getNumericValue() / 1000;
    
    // Calculate hours and minutes
    var hours = Math.floor(totalSeconds / 3600);
    var minutes = Math.floor((totalSeconds % 3600) / 60);
    
    // Format the time as "X Hours Y Minutes"
    var formattedTime = hours + ' Hours ' + minutes + ' Minutes';
    
    return formattedTime;
})(current);

 

Best regards
Thomas