SqlServerDbFunctionsExtensions.DateTrunc Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| DateTrunc(DbFunctions, String, Nullable<DateTimeOffset>) |
Truncates the |
| DateTrunc(DbFunctions, String, Nullable<TimeOnly>) |
Truncates the |
| DateTrunc(DbFunctions, String, Nullable<DateTime>) |
Truncates the |
| DateTrunc(DbFunctions, String, TimeOnly) |
Truncates the |
| DateTrunc(DbFunctions, String, DateTimeOffset) |
Truncates the |
| DateTrunc(DbFunctions, String, DateTime) |
Truncates the |
| DateTrunc(DbFunctions, String, DateOnly) |
Truncates the |
| DateTrunc(DbFunctions, String, Nullable<DateOnly>) |
Truncates the |
DateTrunc(DbFunctions, String, Nullable<DateTimeOffset>)
Truncates the dateTimeOffset to the specified datepart precision.
Corresponds to SQL Server's DATETRUNC(datepart, date).
public static DateTimeOffset? DateTrunc(this Microsoft.EntityFrameworkCore.DbFunctions _, string datepart, DateTimeOffset? dateTimeOffset);
static member DateTrunc : Microsoft.EntityFrameworkCore.DbFunctions * string * Nullable<DateTimeOffset> -> Nullable<DateTimeOffset>
<Extension()>
Public Function DateTrunc (_ As DbFunctions, datepart As String, dateTimeOffset As Nullable(Of DateTimeOffset)) As Nullable(Of DateTimeOffset)
Parameters
The DbFunctions instance.
- datepart
- String
The datepart to truncate to. Can be one of: year, quarter, month, dayofyear,
day, week, iso_week, hour, minute, second, millisecond,
microsecond.
- dateTimeOffset
- Nullable<DateTimeOffset>
The value to truncate.
Returns
The truncated DateTimeOffset value.
Remarks
See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.
Applies to
DateTrunc(DbFunctions, String, Nullable<TimeOnly>)
Truncates the time to the specified datepart precision.
Corresponds to SQL Server's DATETRUNC(datepart, date).
public static TimeOnly? DateTrunc(this Microsoft.EntityFrameworkCore.DbFunctions _, string datepart, TimeOnly? time);
static member DateTrunc : Microsoft.EntityFrameworkCore.DbFunctions * string * Nullable<TimeOnly> -> Nullable<TimeOnly>
<Extension()>
Public Function DateTrunc (_ As DbFunctions, datepart As String, time As Nullable(Of TimeOnly)) As Nullable(Of TimeOnly)
Parameters
The DbFunctions instance.
- datepart
- String
The datepart to truncate to. Can be one of: year, quarter, month, dayofyear,
day, week, iso_week, hour, minute, second, millisecond,
microsecond.
Returns
The truncated TimeOnly value.
Remarks
See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.
Applies to
DateTrunc(DbFunctions, String, Nullable<DateTime>)
Truncates the date to the specified datepart precision.
Corresponds to SQL Server's DATETRUNC(datepart, date).
public static DateTime? DateTrunc(this Microsoft.EntityFrameworkCore.DbFunctions _, string datepart, DateTime? date);
static member DateTrunc : Microsoft.EntityFrameworkCore.DbFunctions * string * Nullable<DateTime> -> Nullable<DateTime>
<Extension()>
Public Function DateTrunc (_ As DbFunctions, datepart As String, date As Nullable(Of DateTime)) As Nullable(Of DateTime)
Parameters
The DbFunctions instance.
- datepart
- String
The datepart to truncate to. Can be one of: year, quarter, month, dayofyear,
day, week, iso_week, hour, minute, second, millisecond,
microsecond.
Returns
The truncated DateTime value.
Remarks
See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.
Applies to
DateTrunc(DbFunctions, String, TimeOnly)
Truncates the time to the specified datepart precision.
Corresponds to SQL Server's DATETRUNC(datepart, date).
public static TimeOnly DateTrunc(this Microsoft.EntityFrameworkCore.DbFunctions _, string datepart, TimeOnly time);
static member DateTrunc : Microsoft.EntityFrameworkCore.DbFunctions * string * TimeOnly -> TimeOnly
<Extension()>
Public Function DateTrunc (_ As DbFunctions, datepart As String, time As TimeOnly) As TimeOnly
Parameters
The DbFunctions instance.
- datepart
- String
The datepart to truncate to. Can be one of: year, quarter, month, dayofyear,
day, week, iso_week, hour, minute, second, millisecond,
microsecond.
- time
- TimeOnly
The value to truncate.
Returns
The truncated TimeOnly value.
Remarks
See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.
Applies to
DateTrunc(DbFunctions, String, DateTimeOffset)
Truncates the dateTimeOffset to the specified datepart precision.
Corresponds to SQL Server's DATETRUNC(datepart, date).
public static DateTimeOffset DateTrunc(this Microsoft.EntityFrameworkCore.DbFunctions _, string datepart, DateTimeOffset dateTimeOffset);
static member DateTrunc : Microsoft.EntityFrameworkCore.DbFunctions * string * DateTimeOffset -> DateTimeOffset
<Extension()>
Public Function DateTrunc (_ As DbFunctions, datepart As String, dateTimeOffset As DateTimeOffset) As DateTimeOffset
Parameters
The DbFunctions instance.
- datepart
- String
The datepart to truncate to. Can be one of: year, quarter, month, dayofyear,
day, week, iso_week, hour, minute, second, millisecond,
microsecond.
- dateTimeOffset
- DateTimeOffset
The value to truncate.
Returns
The truncated DateTimeOffset value.
Remarks
See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.
Applies to
DateTrunc(DbFunctions, String, DateTime)
Truncates the date to the specified datepart precision.
Corresponds to SQL Server's DATETRUNC(datepart, date).
public static DateTime DateTrunc(this Microsoft.EntityFrameworkCore.DbFunctions _, string datepart, DateTime date);
static member DateTrunc : Microsoft.EntityFrameworkCore.DbFunctions * string * DateTime -> DateTime
<Extension()>
Public Function DateTrunc (_ As DbFunctions, datepart As String, date As DateTime) As DateTime
Parameters
The DbFunctions instance.
- datepart
- String
The datepart to truncate to. Can be one of: year, quarter, month, dayofyear,
day, week, iso_week, hour, minute, second, millisecond,
microsecond.
- date
- DateTime
The value to truncate.
Returns
The truncated DateTime value.
Remarks
See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.
Applies to
DateTrunc(DbFunctions, String, DateOnly)
Truncates the date to the specified datepart precision.
Corresponds to SQL Server's DATETRUNC(datepart, date).
public static DateOnly DateTrunc(this Microsoft.EntityFrameworkCore.DbFunctions _, string datepart, DateOnly date);
static member DateTrunc : Microsoft.EntityFrameworkCore.DbFunctions * string * DateOnly -> DateOnly
<Extension()>
Public Function DateTrunc (_ As DbFunctions, datepart As String, date As DateOnly) As DateOnly
Parameters
The DbFunctions instance.
- datepart
- String
The datepart to truncate to. Can be one of: year, quarter, month, dayofyear,
day, week, iso_week, hour, minute, second, millisecond,
microsecond.
- date
- DateOnly
The value to truncate.
Returns
The truncated DateOnly value.
Remarks
See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.
Applies to
DateTrunc(DbFunctions, String, Nullable<DateOnly>)
Truncates the date to the specified datepart precision.
Corresponds to SQL Server's DATETRUNC(datepart, date).
public static DateOnly? DateTrunc(this Microsoft.EntityFrameworkCore.DbFunctions _, string datepart, DateOnly? date);
static member DateTrunc : Microsoft.EntityFrameworkCore.DbFunctions * string * Nullable<DateOnly> -> Nullable<DateOnly>
<Extension()>
Public Function DateTrunc (_ As DbFunctions, datepart As String, date As Nullable(Of DateOnly)) As Nullable(Of DateOnly)
Parameters
The DbFunctions instance.
- datepart
- String
The datepart to truncate to. Can be one of: year, quarter, month, dayofyear,
day, week, iso_week, hour, minute, second, millisecond,
microsecond.
Returns
The truncated DateOnly value.
Remarks
See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.