Date.IsLeapYear

Date

Returns true if the year of the given date is a leap year.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Date.IsLeapYear(dateTime as any) as nullable logical

Parameters

NameTypeRequiredDescription
dateTimeanyYesA date, datetime, or datetimezone value.

Return Value

logicaltrue if the year is a leap year, false otherwise.

Remarks

Date.IsLeapYear returns true if the year component of the input date is a leap year (i.e., divisible by 4, except centuries unless also divisible by 400), and false otherwise. This is equivalent to checking whether Date.DaysInMonth(#date(year, 2, 1)) = 29. If the input is null, the function returns null.

The Gregorian calendar leap year rule: a year is a leap year if it is divisible by 4, except for century years (divisible by 100) which must also be divisible by 400. This is why 2100 is not a leap year despite being divisible by 4.

A practical use for Date.IsLeapYear is adjusting date arithmetic that involves February — for example, when computing annualized rates or building calendar tables that need to account for the extra day. You can also use Date.DaysInMonth on February 1 of the year for the same check, which is sometimes more intuitive.

Examples

Example 1: Flag leap-year orders in the Sales table

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Sales, 5),
        {"OrderID", "OrderDate"}
    ),
    "IsLeapYear", each Date.IsLeapYear([OrderDate]), type logical
)
Result
OrderID
OrderDate
IsLeapYear
111/15/2024TRUE
221/18/2024TRUE
332/1/2024TRUE
442/10/2024TRUE
553/5/2024TRUE

Example 2: Test the leap year rule including century years

#table(
    type table [Year = number, IsLeap = logical],
    {
        {2024, Date.IsLeapYear(#date(2024, 1, 1))},
        {2023, Date.IsLeapYear(#date(2023, 1, 1))},
        {2100, Date.IsLeapYear(#date(2100, 1, 1))},
        {2000, Date.IsLeapYear(#date(2000, 1, 1))}
    }
)
Result
Year
IsLeap
12,024TRUE
22,023FALSE
32,100FALSE
42,000TRUE

Example 3: Compute the number of days in the year

#table(
    type table [Year = number, DaysInYear = number],
    {
        {2024, if Date.IsLeapYear(#date(2024, 1, 1)) then 366 else 365},
        {2023, if Date.IsLeapYear(#date(2023, 1, 1)) then 366 else 365},
        {2100, if Date.IsLeapYear(#date(2100, 1, 1)) then 366 else 365}
    }
)
Result
Year
DaysInYear
12,024366
22,023365
32,100365

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks