GlideDateTime - subtract(GlideDateTime start, GlideDateTime end)

Gets the duration difference between two GlideDateTime values.

Table 1. Parameters
Name Type Description
start GlideDateTime The start value
end GlideDateTime The end value
Table 2. Returns
Type Description
GlideDuration The time between the two values

Scoped equivalent

To use the subtract() method in a scoped application, use the corresponding scoped method: Scoped GlideDateTime - subtract(GlideDateTime start, GlideDateTime end).

var gdt1 = new GlideDateTime("2011-08-28 09:00:00");
var gdt2 = new GlideDateTime("2011-08-31 08:00:00");
var dur = new GlideDuration();
 
var dur = GlideDateTime.subtract(gdt1, gdt2); //the difference between gdt1 and gdt2
gs.print(dur.getDisplayValue());

Output: 2 Days 23 Hours