Edit

Share via


SqlFunctions.DatePart Method

Definition

Returns an integer that represents the specified datepart of the specified date.

Overloads

DatePart(String, Nullable<DateTime>)

Returns an integer that represents the specified datepart of the specified date.

DatePart(String, Nullable<DateTimeOffset>)

Returns an integer that represents the specified datepart of the specified date.

DatePart(String, Nullable<TimeSpan>)

Returns an integer that represents the specified datepart of the specified date.

DatePart(String, String)

Returns an integer that represents the specified datepart of the specified date.

Remarks

You cannot call this function directly. This function can only appear within a LINQ to Entities query.

This function is translated to a corresponding function in the database. For information about the corresponding SQL Server function, see DATEPART (Transact-SQL).

DatePart(String, Nullable<DateTime>)

Returns an integer that represents the specified datepart of the specified date.

public:
 static Nullable<int> DatePart(System::String ^ datePartArg, Nullable<DateTime> date);
[System.Data.Objects.DataClasses.EdmFunction("SqlServer", "DATEPART")]
public static int? DatePart (string datePartArg, DateTime? date);
[<System.Data.Objects.DataClasses.EdmFunction("SqlServer", "DATEPART")>]
static member DatePart : string * Nullable<DateTime> -> Nullable<int>
Public Shared Function DatePart (datePartArg As String, date As Nullable(Of DateTime)) As Nullable(Of Integer)

Parameters

datePartArg
String

The part of the date to return the value.

date
Nullable<DateTime>

The date.

Returns

The specified datepart of the specified date.

Attributes

Remarks

You cannot call this function directly. This function can only appear within a LINQ to Entities query.

This function is translated to a corresponding function in the database. For information about the corresponding SQL Server function, see DATEPART (Transact-SQL).

Applies to

DatePart(String, Nullable<DateTimeOffset>)

Returns an integer that represents the specified datepart of the specified date.

public:
 static Nullable<int> DatePart(System::String ^ datePartArg, Nullable<DateTimeOffset> date);
[System.Data.Objects.DataClasses.EdmFunction("SqlServer", "DATEPART")]
public static int? DatePart (string datePartArg, DateTimeOffset? date);
[<System.Data.Objects.DataClasses.EdmFunction("SqlServer", "DATEPART")>]
static member DatePart : string * Nullable<DateTimeOffset> -> Nullable<int>
Public Shared Function DatePart (datePartArg As String, date As Nullable(Of DateTimeOffset)) As Nullable(Of Integer)

Parameters

datePartArg
String

The part of the date to return the value.

date
Nullable<DateTimeOffset>

The date.

Returns

The specified datepart of the specified date.

Attributes

Remarks

You cannot call this function directly. This function can only appear within a LINQ to Entities query.

This function is translated to a corresponding function in the database. For information about the corresponding SQL Server function, see DATEPART (Transact-SQL).

Applies to

DatePart(String, Nullable<TimeSpan>)

Returns an integer that represents the specified datepart of the specified date.

public:
 static Nullable<int> DatePart(System::String ^ datePartArg, Nullable<TimeSpan> date);
[System.Data.Objects.DataClasses.EdmFunction("SqlServer", "DATEPART")]
public static int? DatePart (string datePartArg, TimeSpan? date);
[<System.Data.Objects.DataClasses.EdmFunction("SqlServer", "DATEPART")>]
static member DatePart : string * Nullable<TimeSpan> -> Nullable<int>
Public Shared Function DatePart (datePartArg As String, date As Nullable(Of TimeSpan)) As Nullable(Of Integer)

Parameters

datePartArg
String

The part of the date to return the value.

date
Nullable<TimeSpan>

The date.

Returns

The specified datepart of the specified date.

Attributes

Remarks

You cannot call this function directly. This function can only appear within a LINQ to Entities query.

This function is translated to a corresponding function in the database. For information about the corresponding SQL Server function, see DATEPART (Transact-SQL).

Applies to

DatePart(String, String)

Returns an integer that represents the specified datepart of the specified date.

public:
 static Nullable<int> DatePart(System::String ^ datePartArg, System::String ^ date);
[System.Data.Objects.DataClasses.EdmFunction("SqlServer", "DATEPART")]
public static int? DatePart (string datePartArg, string date);
[<System.Data.Objects.DataClasses.EdmFunction("SqlServer", "DATEPART")>]
static member DatePart : string * string -> Nullable<int>
Public Shared Function DatePart (datePartArg As String, date As String) As Nullable(Of Integer)

Parameters

datePartArg
String

The part of the date to return the value.

date
String

The date.

Returns

The specified datepart of the specified date.

Attributes

Remarks

You cannot call this function directly. This function can only appear within a LINQ to Entities query.

This function is translated to a corresponding function in the database. For information about the corresponding SQL Server function, see DATEPART (Transact-SQL).

Applies to