0
var startTime = new GlideDateTime("2023-08-01 01:00:00");
  var endTime = new GlideDateTime("2023-08-23 23:10:00");
   var dur = GlideDateTime.subtract(startTime , endTime); 
  gs.print("Actual days with hours ="+dur.getDisplayValue());
  gs.print(dur.getDayPart()); // 
 gs.print(dur.getRoundedDayPart());

Output:

How to calculate difference between two dates in days ServiceNow ?
Working Code Asked question August 22, 2023