DbFunctions.DiffHours Method (Nullable<DateTime>, Nullable<DateTime>)
[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]
When used as part of a LINQ to Entities query, this method invokes the canonical DiffHours EDM function to calculate the number of hours between two date/times.
Namespace: System.Data.Entity
Assembly: EntityFramework (in EntityFramework.dll)
Syntax
'Declaration
<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId := "timeValue1")> _
<DbFunctionAttribute("Edm", "DiffHours")> _
<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId := "timeValue2")> _
Public Shared Function DiffHours ( _
timeValue1 As Nullable(Of DateTime), _
timeValue2 As Nullable(Of DateTime) _
) As Nullable(Of Integer)
'Usage
Dim timeValue1 As Nullable(Of DateTime)
Dim timeValue2 As Nullable(Of DateTime)
Dim returnValue As Nullable(Of Integer)
returnValue = DbFunctions.DiffHours(timeValue1, _
timeValue2)
[SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "timeValue1")]
[DbFunctionAttribute("Edm", "DiffHours")]
[SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "timeValue2")]
public static Nullable<int> DiffHours(
Nullable<DateTime> timeValue1,
Nullable<DateTime> timeValue2
)
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA1801:ReviewUnusedParameters", MessageId = L"timeValue1")]
[DbFunctionAttribute(L"Edm", L"DiffHours")]
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA1801:ReviewUnusedParameters", MessageId = L"timeValue2")]
public:
static Nullable<int> DiffHours(
Nullable<DateTime> timeValue1,
Nullable<DateTime> timeValue2
)
[<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "timeValue1")>]
[<DbFunctionAttribute("Edm", "DiffHours")>]
[<SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "timeValue2")>]
static member DiffHours :
timeValue1:Nullable<DateTime> *
timeValue2:Nullable<DateTime> -> Nullable<int>
public static function DiffHours(
timeValue1 : Nullable<DateTime>,
timeValue2 : Nullable<DateTime>
) : Nullable<int>
Parameters
- timeValue1
Type: System.Nullable<DateTime>
The first date/time.
- timeValue2
Type: System.Nullable<DateTime>
The second date/time.
Return Value
Type: System.Nullable<Int32>
The number of hours between the first and second date/times.
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.