Table of Contents

Method Truncate

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

Truncate(DateTime, DateTimeUnit)

Truncates a DateTime value to the specified unit.

public static DateTime Truncate(this DateTime @this, DateTimeUnit unit)

Parameters

this DateTime

The original DateTime.

unit DateTimeUnit

The unit.

Returns

DateTime

The resulting DateTime.

Truncate(DateTime, DateTimeUnit, long)

Truncates a DateTime value to the specified unit and bin size.

public static DateTime Truncate(this DateTime @this, DateTimeUnit unit, long binSize)

Parameters

this DateTime

The original DateTime.

unit DateTimeUnit

The unit.

binSize long

The bin size.

Returns

DateTime

The resulting DateTime.

Truncate(DateTime, DateTimeUnit, long, string)

Truncates a DateTime value to the specified unit and bin size taking a timezone into consideration.

public static DateTime Truncate(this DateTime @this, DateTimeUnit unit, long binSize, string timezone)

Parameters

this DateTime

The original DateTime.

unit DateTimeUnit

The unit.

binSize long

The bin size.

timezone string

The timezone.

Returns

DateTime

The resulting DateTime.

Remarks

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