Home > FAQ > Data Manipulation > Date Rounding in Expressions > End of the current ... examples > End of the current calendar year

End of the current calendar year

This is the recommended expression for rounding dates to the end of the current calendar year:

EOY_DT:= #ENDMTH (1 #LSTBUSDAY A_DT) &
; find the last business day of the current calendar year, then round that last business day
; (i.e., 12/29, 12/30, or 12/31) to the end of the month (i.e., 12/31)

A_DT may be either a single date (e.g., 7/16/2015, DOH, #DODEC) or an array of dates (e.g., #DATE). 

We start with #LSTBUSDAY because it's the easiest way to work with plan years but can be generalized to calendar years. We then use #ENDMTH to guarantee that we are at the end of the current calendar year. 1 #LSTBUSDAY A_DT finds the last business day of the current calendar year, which is either 12/31, 12/30, or 12/29 of the current calendar year, depending on whether the last day of the current calendar year is a weekday, Sunday or Saturday. Then, #ENDMTH converts it to the last day of the month (i.e., the 12/31).

If you have already calculated the beginning of the next calendar year for each date in A_DT (e.g., stored in BOY1_DT), then simply subtracting 1 day gives you the end of the current calendar year:

EOY_DT:= BOY1_DT - 1 &