SqlFunctions.DateDiff Method

Definition

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.

DateDiff(String, String, String)

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

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
public static Nullable<int> DateDiff (string datePartArg, string startDate, string endDate);
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

Applies to

DateDiff(String, String, Nullable<TimeSpan>)

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

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
public static Nullable<int> DateDiff (string datePartArg, string startDate, Nullable<TimeSpan> endDate);
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

Applies to

DateDiff(String, String, Nullable<DateTimeOffset>)

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

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
public static Nullable<int> DateDiff (string datePartArg, string startDate, Nullable<DateTimeOffset> endDate);
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

Applies to

DateDiff(String, String, Nullable<DateTime>)

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

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
public static Nullable<int> DateDiff (string datePartArg, string startDate, Nullable<DateTime> endDate);
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

Applies to

DateDiff(String, Nullable<TimeSpan>, String)

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

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<TimeSpan> startDate, string endDate);
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

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.

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<TimeSpan> startDate, Nullable<TimeSpan> endDate);
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

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.

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<TimeSpan> startDate, Nullable<DateTimeOffset> endDate);
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

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.

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<TimeSpan> startDate, Nullable<DateTime> endDate);
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

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.

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<DateTimeOffset> startDate, Nullable<DateTimeOffset> endDate);
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

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.

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<DateTimeOffset> startDate, Nullable<TimeSpan> endDate);
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

Applies to

DateDiff(String, Nullable<DateTimeOffset>, String)

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

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<DateTimeOffset> startDate, string endDate);
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

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.

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<DateTimeOffset> startDate, Nullable<DateTime> endDate);
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

Applies to

DateDiff(String, Nullable<DateTime>, String)

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

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<DateTime> startDate, string endDate);
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

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.

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<DateTime> startDate, Nullable<TimeSpan> endDate);
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

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.

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<DateTime> startDate, Nullable<DateTimeOffset> endDate);
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

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.

[System.Data.Entity.DbFunction("SqlServer", "DATEDIFF")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="startDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="endDate")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId="datePartArg")]
public static Nullable<int> DateDiff (string datePartArg, Nullable<DateTime> startDate, Nullable<DateTime> endDate);
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

Applies to