datetime.diff()

Determines the number of given date parts between two different dates

datetime.diff( datePart=string, date1=datetime )

Returns: Number

Argument Description
datePart
string, required

String that specifies the units in which to count:

  • yyyy: Years
  • q: Quarters
  • m: Months
  • y: Day of Year (same as d)
  • d: Days (same as y)
  • w: Weeks (same as ww)
  • ww: Weeks (same as w)
  • h: Hours
  • n: Minutes
  • s: Seconds
date1
datetime, required

date time object to compare

Examples

date = createDateTime(1997,04,11);
	echo( date.Diff("d", "1997-04-25") & "<br>"); // 1
	dateOne = createDate(1997,04,11);
	echo( dateOne.Diff("d", "1997-04-11") & "<br>"); // 0
	datetime = createDateTime(1992,12,11,01,00,00);
	echo( datetime.Diff("h", "1992-12-11 00:00:00") & "<br>"); // -1

See also