Språk

SqlServerDbFunctionsExtensions.DateTrunc Method

Definition

Overloads

Name Description
DateTrunc(DbFunctions, String, Nullable<DateTimeOffset>)

Truncates the dateTimeOffset to the specified datepart precision. Corresponds to SQL Server's DATETRUNC(datepart, date).

DateTrunc(DbFunctions, String, Nullable<TimeOnly>)

Truncates the time to the specified datepart precision. Corresponds to SQL Server's DATETRUNC(datepart, date).

DateTrunc(DbFunctions, String, Nullable<DateTime>)

Truncates the date to the specified datepart precision. Corresponds to SQL Server's DATETRUNC(datepart, date).

DateTrunc(DbFunctions, String, TimeOnly)

Truncates the time to the specified datepart precision. Corresponds to SQL Server's DATETRUNC(datepart, date).

DateTrunc(DbFunctions, String, DateTimeOffset)

Truncates the dateTimeOffset to the specified datepart precision. Corresponds to SQL Server's DATETRUNC(datepart, date).

DateTrunc(DbFunctions, String, DateTime)

Truncates the date to the specified datepart precision. Corresponds to SQL Server's DATETRUNC(datepart, date).

DateTrunc(DbFunctions, String, DateOnly)

Truncates the date to the specified datepart precision. Corresponds to SQL Server's DATETRUNC(datepart, date).

DateTrunc(DbFunctions, String, Nullable<DateOnly>)

Truncates the date to the specified datepart precision. Corresponds to SQL Server's DATETRUNC(datepart, date).

DateTrunc(DbFunctions, String, Nullable<DateTimeOffset>)

Source:
SqlServerDbFunctionsExtensions.cs

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

_
DbFunctions

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>)

Source:
SqlServerDbFunctionsExtensions.cs

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

_
DbFunctions

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
Nullable<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, Nullable<DateTime>)

Source:
SqlServerDbFunctionsExtensions.cs

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

_
DbFunctions

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
Nullable<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, TimeOnly)

Source:
SqlServerDbFunctionsExtensions.cs

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

_
DbFunctions

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)

Source:
SqlServerDbFunctionsExtensions.cs

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

_
DbFunctions

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)

Source:
SqlServerDbFunctionsExtensions.cs

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

_
DbFunctions

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)

Source:
SqlServerDbFunctionsExtensions.cs

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

_
DbFunctions

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>)

Source:
SqlServerDbFunctionsExtensions.cs

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

_
DbFunctions

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
Nullable<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