Table of Contents

Method Subtract

Namespace
MongoDB.Driver.Linq
Assembly
MongoDB.Driver.dll

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 DateTime

The original DateTime.

startDate DateTime

The start date.

unit DateTimeUnit

The 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 DateTime

The original DateTime.

startDate DateTime

The start date.

unit DateTimeUnit

The unit.

timezone string

The 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 DateTime

The original DateTime.

value DateTime

The value to be added.

timezone string

The 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 DateTime

The original DateTime.

value TimeSpan

The value to be added.

timezone string

The 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 DateTime

The original DateTime.

value long

The value to be added.

unit DateTimeUnit

The 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 DateTime

The original DateTime.

value long

The value to be added.

unit DateTimeUnit

The unit.

timezone string

The timezone.

Returns

DateTime

The resulting DateTime.

Remarks

See the server documentation for $dateSubtract for information on timezones in MongoDB.