SqlFunctions.DateDiff 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回跨越兩個指定日期的日期和時間界線數目。
多載
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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 to 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
第一個日期。
傳回
指定兩個日期之間的時間間隔數目的值。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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 to 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
第一個日期。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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
要計算時間間隔數目差異的日期部分。
- endDate
- String
第二個日期。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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
要計算時間間隔數目差異的日期部分。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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
要計算時間間隔數目差異的日期部分。
- endDate
- Nullable<DateTimeOffset>
第二個日期。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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
要計算時間間隔數目差異的日期部分。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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 to 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>
第一個日期。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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 to 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>
第一個日期。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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
要計算時間間隔數目差異的日期部分。
- endDate
- String
第二個日期。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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
要計算時間間隔數目差異的日期部分。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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
要計算時間間隔數目差異的日期部分。
- endDate
- Nullable<DateTimeOffset>
第二個日期。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to 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
要計算時間間隔數目差異的日期部分。
傳回
兩個日期之間的時間間隔數目。
- 屬性
備註
您無法直接呼叫此函式。 此函式只能出現在 LINQ to Entities 查詢內。
此函式會轉譯為資料庫中的對應函式。 如需對應 SQL Server 函數的相關信息,請參閱 DATEDIFF (Transact-SQL) 。