Method Truncate
Truncate(DateTime, DateTimeUnit)
Truncates a DateTime value to the specified unit.
public static DateTime Truncate(this DateTime @this, DateTimeUnit unit)
Parameters
thisDateTimeThe original DateTime.
unitDateTimeUnitThe 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
thisDateTimeThe original DateTime.
unitDateTimeUnitThe unit.
binSizelongThe 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
thisDateTimeThe original DateTime.
unitDateTimeUnitThe unit.
binSizelongThe bin size.
timezonestringThe timezone.
Returns
- DateTime
The resulting DateTime.
Remarks
See the server documentation for $dateTrunc for information on timezones in MongoDB.