cancel
Showing results for 
Search instead for 
Did you mean: 

Leap Year

Super User
263 Views
Highlighted
Super User
Super User

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 && NOT(__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 && NOT(__Div400),TRUE(),FALSE()))
RETURN __IsLeapYear

 


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!