DateTimeOffsetExtensionsMonthsBetween Method |
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 DateTimeOffset(2012, 1, 1, 0, 0, 0, TimeSpan.Zero);
var secondDate = new DateTimeOffset(2010, 1, 1, 0, 0, 0, TimeSpan.Zero);
? firstDate.MonthsBetween(secondDate);
See Also