Method Subtract
Subtract(DateTime, DateTime, DateTimeUnit)
Subtracts the start date from the end date returning the result in the specified unit.
public static long Subtract(this DateTime @this, DateTime startDate, DateTimeUnit unit)
Parameters
this
DateTimeThe original DateTime.
startDate
DateTimeThe start date.
unit
DateTimeUnitThe unit.
Returns
- long
The result.
Subtract(DateTime, DateTime, DateTimeUnit, string)
Subtracts the start date from the end date returning the result in the specified unit taking a timezone into consideration.
public static long Subtract(this DateTime @this, DateTime startDate, DateTimeUnit unit, string timezone)
Parameters
this
DateTimeThe original DateTime.
startDate
DateTimeThe start date.
unit
DateTimeUnitThe unit.
timezone
stringThe timezone.
Returns
- long
The result.
Remarks
See the server documentation for $dateDiff for information on timezones in MongoDB.
Subtract(DateTime, DateTime, string)
Subtracts the start date from the end date returning a TimeSpan taking a timezone into consideration.
public static TimeSpan Subtract(this DateTime @this, DateTime value, string timezone)
Parameters
this
DateTimeThe original DateTime.
value
DateTimeThe value to be added.
timezone
stringThe timezone.
Returns
- TimeSpan
The resulting DateTime.
Remarks
See the server documentation for $dateDiff for information on timezones in MongoDB.
Subtract(DateTime, TimeSpan, string)
Subtracts a TimeSpan from a date taking a timezone into consideration.
public static DateTime Subtract(this DateTime @this, TimeSpan value, string timezone)
Parameters
this
DateTimeThe original DateTime.
value
TimeSpanThe value to be added.
timezone
stringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateSubtract for information on timezones in MongoDB.
Subtract(DateTime, long, DateTimeUnit)
Subtracts a value of the specified unit from a DateTime.
public static DateTime Subtract(this DateTime @this, long value, DateTimeUnit unit)
Parameters
this
DateTimeThe original DateTime.
value
longThe value to be added.
unit
DateTimeUnitThe unit.
Returns
- DateTime
The resulting DateTime.
Subtract(DateTime, long, DateTimeUnit, string)
Subtracts a value of the specified unit from a DateTime taking a timezone into consideration.
public static DateTime Subtract(this DateTime @this, long value, DateTimeUnit unit, string timezone)
Parameters
this
DateTimeThe original DateTime.
value
longThe value to be added.
unit
DateTimeUnitThe unit.
timezone
stringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateSubtract for information on timezones in MongoDB.