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