DateTimeExtensionsMonthsBetween Method |
Returns the total number of months between two
DateTime values.
Namespace: InnerDrive.CoreAssembly: InnerDrive.Core (in InnerDrive.Core.dll) Version: 5.0.8475.0
Syntax Remarks
Only the
Month portions of the values are considered.
The parameters firstDate and secondDate
may be specified in any order. If firstDate is
less than or equal to secondDate, a positive number will be returned.
If firstDate is larger, a negative number will be returned.
First date | Second date | Result |
---|
2001-01-01 | 2001-03-31 | 2 |
2001-01-31 | 2001-03-01 | 2 |
2001-01-01 | 2001-01-31 | 0 |
2001-01-31 | 2001-01-01 | 0 |
2001-01-01 | 2000-12-31 | -1 |
Example var firstDate = new DateTime(2002, 1, 1);
var secondDate = new DateTime(2003, 1, 1);
? firstDate.MonthsBetween(secondDate);
See Also