Home > FAQ > Data Manipulation > Date Rounding in Expressions > How many days in examples > How many days in an anniversary year

How many days in an anniversary year

The simplest way to find the number of days in an anniversary year is to find the beginning and end of the current anniversary year, or the end of the current and previous plan years.

 

; A_DT is a single date or an array of date(s) that you need to
; adjust (e.g., DOB field or #DATE in a transformation expression)

 

; works for any date except for leap dates (2/29/yyyy)

 

; Method 1: ------------------------------------------
AnyBOY_DT:= 4/23/1956 & ; any beginning of anniversary date
BOY_DT:= AnyBOY_DT #DATEPLUS ((#FLOOR (A_DT #YEARDIF AnyBOY_DT))*1Y) &
BOY1_DT:= BOY_DT #DATEPLUS 1Y &
DaysInYear:= BOY1_DT – BOY_DT &

 

; Method 2: ------------------------------------------
AnyEOY_DT:= 4/22/1956 & ; any end of plan year date
EOY_DT:= (AnyBOY_DT #DATEPLUS((1+#FLOOR(A_DT #YEARDIF AnyBOY_DT))*1Y))-1 &
PrevEOY_DT:= EOY_DT #DATEMINUS 1Y &
DaysInYear:= EOY_DT – PrevEOY_DT &