SqlMethods.DateDiffMonth 方法

定义

计算两个指定日期之间的月边界数。

重载

名称 说明
DateDiffMonth(DateTime, DateTime)

计算两个不可为 null 的日期之间的月份边界数。

DateDiffMonth(DateTimeOffset, DateTimeOffset)

计算两个不可为 null 的日期之间的月份边界数。

DateDiffMonth(Nullable<DateTime>, Nullable<DateTime>)

计算两个可为 null 日期之间的月份边界数。

DateDiffMonth(Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

计算两个可为 null 日期之间的月份边界数。

注解

对应于使用 DATEDIFF 指定跨越的时间边界类型的 SQL Server month 函数。 有关此SQL Server函数的详细信息,请参阅 DATEDIFF

DateDiffMonth(DateTime, DateTime)

计算两个不可为 null 的日期之间的月份边界数。

public:
 static int DateDiffMonth(DateTime startDate, DateTime endDate);
public static int DateDiffMonth(DateTime startDate, DateTime endDate);
static member DateDiffMonth : DateTime * DateTime -> int
Public Shared Function DateDiffMonth (startDate As DateTime, endDate As DateTime) As Integer

参数

startDate
DateTime

时间段的开始日期。

endDate
DateTime

时间段的结束日期。

返回

两个指定日期之间的月边界数。

注解

对应于使用 DATEDIFF 指定跨越的时间边界类型的 SQL Server month 函数。 有关此SQL Server函数的详细信息,请参阅 DATEDIFF

适用于

DateDiffMonth(DateTimeOffset, DateTimeOffset)

计算两个不可为 null 的日期之间的月份边界数。

public:
 static int DateDiffMonth(DateTimeOffset startDate, DateTimeOffset endDate);
public static int DateDiffMonth(DateTimeOffset startDate, DateTimeOffset endDate);
static member DateDiffMonth : DateTimeOffset * DateTimeOffset -> int
Public Shared Function DateDiffMonth (startDate As DateTimeOffset, endDate As DateTimeOffset) As Integer

参数

startDate
DateTimeOffset

时间段的开始日期。

endDate
DateTimeOffset

时间段的结束日期。

返回

两个指定日期之间的月边界数。

注解

对应于使用 DATEDIFF 指定跨越的时间边界类型的 SQL Server month 函数。 有关此SQL Server函数的详细信息,请参阅 DATEDIFF

适用于

DateDiffMonth(Nullable<DateTime>, Nullable<DateTime>)

计算两个可为 null 日期之间的月份边界数。

public:
 static Nullable<int> DateDiffMonth(Nullable<DateTime> startDate, Nullable<DateTime> endDate);
public static int? DateDiffMonth(DateTime? startDate, DateTime? endDate);
static member DateDiffMonth : Nullable<DateTime> * Nullable<DateTime> -> Nullable<int>
Public Shared Function DateDiffMonth (startDate As Nullable(Of DateTime), endDate As Nullable(Of DateTime)) As Nullable(Of Integer)

参数

startDate
Nullable<DateTime>

时间段的开始日期。

endDate
Nullable<DateTime>

时间段的结束日期。

返回

如果两个参数都不是 null,则返回两个指定日期之间的月份边界数。 当一个或两个参数都是 null时,返回一个 null 值。

注解

对应于使用 DATEDIFF 指定跨越的时间边界类型的 SQL Server month 函数。 有关此SQL Server函数的详细信息,请参阅 DATEDIFF

适用于

DateDiffMonth(Nullable<DateTimeOffset>, Nullable<DateTimeOffset>)

计算两个可为 null 日期之间的月份边界数。

public:
 static Nullable<int> DateDiffMonth(Nullable<DateTimeOffset> startDate, Nullable<DateTimeOffset> endDate);
public static int? DateDiffMonth(DateTimeOffset? startDate, DateTimeOffset? endDate);
static member DateDiffMonth : Nullable<DateTimeOffset> * Nullable<DateTimeOffset> -> Nullable<int>
Public Shared Function DateDiffMonth (startDate As Nullable(Of DateTimeOffset), endDate As Nullable(Of DateTimeOffset)) As Nullable(Of Integer)

参数

startDate
Nullable<DateTimeOffset>

时间段的开始日期。

endDate
Nullable<DateTimeOffset>

时间段的结束日期。

返回

如果两个参数都不是 null,则返回两个指定日期之间的月份边界数。 当一个或两个参数都是 null时,返回一个 null 值。

注解

对应于使用 DATEDIFF 指定跨越的时间边界类型的 SQL Server month 函数。 有关此SQL Server函数的详细信息,请参阅 DATEDIFF

适用于