Scoped GlideDateTime - compareTo(Object o)

Compares two date and time objects to determine whether they are equivalent or one occurs before or after the other.

Table 1. Parameters
Name Type Description
o Object Date and time object in GlideDateTime format
Table 2. Returns
Type Description
Number
  • 0 = Dates are equal
  • 1 = Initial date is before the compare date
  • -1 = Initial date is after the compare date
var initDate = new GlideDateTime("2011-08-01 12:00:00");
var compDate1 = new GlideDateTime("2011-08-01 12:00:00");
var compDate2 = new GlideDateTime("2011-07-31 12:00:00");
var compDate3 = new GlideDateTime("2011-08-04 16:00:00");
 
gs.info(initDate.compareTo(compDate1)); // Equals
gs.info(initDate.compareTo(compDate2)); // Earlier than
gs.info(initDate.compareTo(compDate3)); // Later than