SqlFunctions.DateDiff Method

Definition

Returns the number of date and time boundaries crossed between two specified dates.

Overloads

DateDiff(String, String, String)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, String, Nullable<TimeSpan>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, String, Nullable<DateTimeOffset>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, String, Nullable<DateTime>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<TimeSpan>, String)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<TimeSpan>, Nullable<TimeSpan>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<TimeSpan>, Nullable<DateTimeOffset>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<TimeSpan>, Nullable<DateTime>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<DateTimeOffset>, Nullable<TimeSpan>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<DateTimeOffset>, String)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<DateTimeOffset>, Nullable<DateTime>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<DateTime>, String)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<DateTime>, Nullable<TimeSpan>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<DateTime>, Nullable<DateTimeOffset>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

DateDiff(String, Nullable<DateTime>, Nullable<DateTime>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end 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 DATEDIFF (Transact-SQL).

DateDiff(String, String, String)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
String

The first date.

endDate
String

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, String, Nullable<TimeSpan>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
String

The first date.

endDate
Nullable<TimeSpan>

The second date.

Returns

The value specifying the number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, String, Nullable<DateTimeOffset>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
String

The first date.

endDate
Nullable<DateTimeOffset>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, String, Nullable<DateTime>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
String

The first date.

endDate
Nullable<DateTime>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<TimeSpan>, String)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<TimeSpan>

The first date.

endDate
String

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<TimeSpan>, Nullable<TimeSpan>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<TimeSpan>

The first date.

endDate
Nullable<TimeSpan>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<TimeSpan>, Nullable<DateTimeOffset>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<TimeSpan>

The first date.

endDate
Nullable<DateTimeOffset>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<TimeSpan>, Nullable<DateTime>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<TimeSpan>

The first date.

endDate
Nullable<DateTime>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<DateTimeOffset>

The first date.

endDate
Nullable<DateTimeOffset>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<DateTimeOffset>, Nullable<TimeSpan>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<DateTimeOffset>

The first date.

endDate
Nullable<TimeSpan>

The second date.

Returns

The number of time intervals between the two Dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<DateTimeOffset>, String)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<DateTimeOffset>

The first date.

endDate
String

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<DateTimeOffset>, Nullable<DateTime>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<DateTimeOffset>

The first date.

endDate
Nullable<DateTime>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<DateTime>, String)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<DateTime>

The first date.

endDate
String

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<DateTime>, Nullable<TimeSpan>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<DateTime>

The first date.

endDate
Nullable<TimeSpan>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<DateTime>, Nullable<DateTimeOffset>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<DateTime>

The first date.

endDate
Nullable<DateTimeOffset>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to

DateDiff(String, Nullable<DateTime>, Nullable<DateTime>)

Returns the count of the specified datepart boundaries crossed between the specified start date and end date.

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

Parameters

datePartArg
String

The part of the date to calculate the differing number of time intervals.

startDate
Nullable<DateTime>

The first date.

endDate
Nullable<DateTime>

The second date.

Returns

The number of time intervals between the two dates.

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 DATEDIFF (Transact-SQL).

Applies to