#INLEAPYR
Returns 1 if a date is in a leap year (i.e., the year contains the leap day, 2/29) or 0 if the date is in a non-leap year. For calendar years, most dates within a year evenly divisible by 4 are leap years; centuries are leap years only if they are divisible by 400, e.g., 2000, but not 1900 or 2100.
Syntax:
a #INLEAPYR b
a is optional. If a is 1 or missing, calendar years are considered. If a is 0, plan years are considered.
b is a date (e.g., 1/1/2007, #DATE, date fieldname (where appropriate), or a value created by assignment B_DT)
Examples:
#INLEAPYR 1/31/2008 equals 1, because the calendar year 2008 is a leap year.
1 #INLEAPYR 1/31/2008 equals 1, because the calendar year 2008 is a leap year.
0 #INLEAPYR 1/31/2008 may be 0 or 1 depending on the plan year start date or rather, depending on whether the plan year that contains 1/31/2008 also contains 2/29/2008. If the plan year begins January 1st, the result is 1 because 2008 is a leap year. If the plan year begins February 1st, the result is 0 because the plan year [2/1/2007, 1/31/2008] does not contain a leap day, so it is not a leap year. If the plan year begins April 1st, the result is 1 because the plan year [4/1/2007, 3/31/2008] does contains 2/29/2008.#INLEAPYR #DATE is a vector of zeros and ones, where the ones indicate that a calculation date is in a calendar leap year, and zeros indicated that a calculation date is not in a calendar leap year.
0 #INLEAPYR #DATE is a vector of zeros and ones, where the ones indicate that a calculation date is in a plan leap year, and zeros indicated that a calculation date is not in a plan leap year.
In a calendar leap year, is a date before or after the leap date:
B:= #INLEAPYR #DATE &; is the date in a plan leap year (i.e., does the plan year containing this date also have a leap day)
M:= #MONTH #DATE &
D:= #DAY #DATE &
C:= (M > 3) #OR ((M=2) #AND (D=29)) &
B #AND C ; indicates calculation dates in a leap year that are on or after the leap date
In a plan leap year (January or February plan year), is a date before or after the leap date:
B:= 0 #INLEAPYR #DATE & ; is the date in a plan leap year (i.e., does the plan year containing this date also have a leap day)
Yr= #YEAR (2 #FSTBUSDAY #DATE) & ; for Jan, Feb the year of the 1st day of the plan year determines the year of the leap day
L_DT:=(3/1/1900 #DATEPLUS (1Y * (Yr-1900))) - 1 & ; start with 3/1 and subtract 1 day to get the leap date (or 2/28 in non-leap years)
B #AND (#DATE >= L_DT)
In a plan leap year (March, April, May, ..., or December plan year), is a date before or after the leap date:
B:= 0 #INLEAPYR #DATE &; is the date in a plan leap year (i.e., does the plan year containing this date also have a leap day)
Yr= #YEAR (2 #LSTBUSDAY #DATE) & ; for March or later plan years, the last day of the plan year determines the year of the leap day
L_DT:=(3/1/1900 #DATEPLUS (1Y * (Yr-1900))) - 1 & ; start with 3/1 and subtract 1 day to get the leap date (or 2/28 in non-leap years)
B #AND (#DATE >= L_DT)