datetime.compare()

Compares to date, to the given optional resolution.

Returns -1 if date1 is before date2. Returns 1 if date1 is after date2. Returns 0 if equal

datetime.compare( date2=datetime, datepart=string )

Returns: Number

Argument Description
date2
datetime, required

datetime object

datepart
string, optional

Precision of the comparison:

  • s (default): Precise to the second
  • n: Precise to the minute
  • h: Precise to the hour
  • d: Precise to the day
  • m: Precise to the month
  • yyyy: Precise to the year

Examples

dateTime = now();
	writeDump(datetime.compare("11/04/1997"));
	dateTimeone = "11/04/1997";
	writeDump(dateTimeone.compare("11/04/1997"));
	dateTimetwo = "27/10/1996";
	writeDump(dateTimetwo.compare(now()));	
	dateTimet1= createDateTime(1997,04,11,08,10,00);
	dateTimet2= createDateTime(1997,04,11,08,15,00);
	writeDump(dateTimet1.compare(dateTimet2));

See also