SqlServerDbFunctionsExtensions.DateDiffMonth Method

Definition

Overloads

DateDiffMonth(DbFunctions, DateOnly, DateOnly)

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

DateDiffMonth(DbFunctions, DateTime, DateTime)

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

DateDiffMonth(DbFunctions, DateTimeOffset, DateTimeOffset)

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

DateDiffMonth(DbFunctions, Nullable<DateOnly>, Nullable<DateOnly>)

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

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

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

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

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

DateDiffMonth(DbFunctions, DateOnly, DateOnly)

Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

C#
public static int DateDiffMonth (this Microsoft.EntityFrameworkCore.DbFunctions _, DateOnly startDate, DateOnly endDate);

Parameters

_
DbFunctions

The DbFunctions instance.

startDate
DateOnly

Starting date for the calculation.

endDate
DateOnly

Ending date for the calculation.

Returns

Number of month boundaries crossed between the dates.

Remarks

See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.

Applies to

Entity Framework Core 9.0 and Entity Framework Core 8.0
Product Versions
Entity Framework Core 8.0, 9.0

DateDiffMonth(DbFunctions, DateTime, DateTime)

Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

C#
public static int DateDiffMonth (this Microsoft.EntityFrameworkCore.DbFunctions _, DateTime startDate, DateTime endDate);

Parameters

_
DbFunctions

The DbFunctions instance.

startDate
DateTime

Starting date for the calculation.

endDate
DateTime

Ending date for the calculation.

Returns

Number of month boundaries crossed between the dates.

Remarks

See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

DateDiffMonth(DbFunctions, DateTimeOffset, DateTimeOffset)

Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

C#
public static int DateDiffMonth (this Microsoft.EntityFrameworkCore.DbFunctions _, DateTimeOffset startDate, DateTimeOffset endDate);

Parameters

_
DbFunctions

The DbFunctions instance.

startDate
DateTimeOffset

Starting date for the calculation.

endDate
DateTimeOffset

Ending date for the calculation.

Returns

Number of month boundaries crossed between the dates.

Remarks

See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

DateDiffMonth(DbFunctions, Nullable<DateOnly>, Nullable<DateOnly>)

Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

C#
public static int? DateDiffMonth (this Microsoft.EntityFrameworkCore.DbFunctions _, DateOnly? startDate, DateOnly? endDate);

Parameters

_
DbFunctions

The DbFunctions instance.

startDate
Nullable<DateOnly>

Starting date for the calculation.

endDate
Nullable<DateOnly>

Ending date for the calculation.

Returns

Number of month boundaries crossed between the dates.

Remarks

See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.

Applies to

Entity Framework Core 9.0 and Entity Framework Core 8.0
Product Versions
Entity Framework Core 8.0, 9.0

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

Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

C#
public static int? DateDiffMonth (this Microsoft.EntityFrameworkCore.DbFunctions _, DateTime? startDate, DateTime? endDate);

Parameters

_
DbFunctions

The DbFunctions instance.

startDate
Nullable<DateTime>

Starting date for the calculation.

endDate
Nullable<DateTime>

Ending date for the calculation.

Returns

Number of month boundaries crossed between the dates.

Remarks

See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

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

Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs
Source:
SqlServerDbFunctionsExtensions.cs

Counts the number of month boundaries crossed between the startDate and endDate. Corresponds to SQL Server's DATEDIFF(month, @startDate, @endDate).

C#
public static int? DateDiffMonth (this Microsoft.EntityFrameworkCore.DbFunctions _, DateTimeOffset? startDate, DateTimeOffset? endDate);

Parameters

_
DbFunctions

The DbFunctions instance.

startDate
Nullable<DateTimeOffset>

Starting date for the calculation.

endDate
Nullable<DateTimeOffset>

Ending date for the calculation.

Returns

Number of month boundaries crossed between the dates.

Remarks

See Database functions, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0