cancel
Showing results for
Search instead for
Did you mean:

# Leap Year

Super User IV
1244 Views
Highlighted
Super User IV

## Leap Year

Simple leap year calculations for returning days in year and whether or not a year is a leap year.

DaysInYear

```DaysInYear =
VAR __Year = INT(MAX(Years[Year]))
VAR __Div4 = IF(MOD(__Year,4)=0,TRUE(),FALSE())
VAR __Div100 = IF(MOD(__Year,100)=0,TRUE(),FALSE())
VAR __Div400 = IF(MOD(__Year,400)=0,TRUE(),FALSE())
VAR __IsLeapYear = IF(__Div4 && NOT(__Div100),TRUE(),IF(__Div4 && __Div100 && __Div400,TRUE(),FALSE()))
VAR __DaysInYear = IF(__IsLeapYear,366,365)
RETURN __DaysInYear```

IsLeapYear

```IsLeapYear =
VAR __Year = INT(MAX(Years[Year]))
VAR __Div4 = IF(MOD(__Year,4)=0,TRUE(),FALSE())
VAR __Div100 = IF(MOD(__Year,100)=0,TRUE(),FALSE())
VAR __Div400 = IF(MOD(__Year,400)=0,TRUE(),FALSE())
VAR __IsLeapYear = IF(__Div4 && NOT(__Div100),TRUE(),IF(__Div4 && __Div100 && __Div400,TRUE(),FALSE()))
RETURN __IsLeapYear```

---------------------------------------

Putting square pegs in round holes since 1972.

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!