SqlFunctions.DateDiff 方法

定義

傳回在兩個指定日期之間跨越的日期和時間界限數目。

多載

名稱 Description
DateDiff(String, String, String)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

DateDiff(String, String, Nullable<TimeSpan>)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

DateDiff(String, String, Nullable<DateTimeOffset>)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

DateDiff(String, String, Nullable<DateTime>)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

DateDiff(String, Nullable<TimeSpan>, String)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

DateDiff(String, Nullable<DateTimeOffset>, String)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

DateDiff(String, Nullable<DateTime>, String)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

DateDiff(String, String, String)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
String

第一次約會。

endDate
String

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

DateDiff(String, String, Nullable<TimeSpan>)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
String

第一次約會。

endDate
Nullable<TimeSpan>

第二次約會。

傳回

該值表示兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

DateDiff(String, String, Nullable<DateTimeOffset>)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
String

第一次約會。

endDate
Nullable<DateTimeOffset>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

DateDiff(String, String, Nullable<DateTime>)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
String

第一次約會。

endDate
Nullable<DateTime>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

DateDiff(String, Nullable<TimeSpan>, String)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<TimeSpan>

第一次約會。

endDate
String

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<TimeSpan>

第一次約會。

endDate
Nullable<TimeSpan>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<TimeSpan>

第一次約會。

endDate
Nullable<DateTimeOffset>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<TimeSpan>

第一次約會。

endDate
Nullable<DateTime>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<DateTimeOffset>

第一次約會。

endDate
Nullable<DateTimeOffset>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<DateTimeOffset>

第一次約會。

endDate
Nullable<TimeSpan>

第二次約會。

傳回

兩次日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

DateDiff(String, Nullable<DateTimeOffset>, String)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<DateTimeOffset>

第一次約會。

endDate
String

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<DateTimeOffset>

第一次約會。

endDate
Nullable<DateTime>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

DateDiff(String, Nullable<DateTime>, String)

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<DateTime>

第一次約會。

endDate
String

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<DateTime>

第一次約會。

endDate
Nullable<TimeSpan>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<DateTime>

第一次約會。

endDate
Nullable<DateTimeOffset>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於

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

回傳指定日期段邊界在指定開始日期與結束日期之間穿越的計數。

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)

參數

datePartArg
String

日期的部分用來計算不同數量的時間間隔。

startDate
Nullable<DateTime>

第一次約會。

endDate
Nullable<DateTime>

第二次約會。

傳回

兩個日期之間的時間間隔數。

屬性

備註

你不能直接呼叫這個函式。 此函式只能出現在 LINQ 對 Entities 查詢中。

這個函式會被轉換成資料庫中的對應函式。 關於對應的SQL Server函數,請參見 DATEDIFF (Transact-SQL).

適用於