The following function returns the date of the last day of the year of the specified date, using date math only. This makes the calculation independent of the current SET DATE setting. The function relies on another function that returns the last day of the month of a specified date.

function LDoY( dArg )

   local dDec 

   dDec = dArg - day( dArg ) + 28 * ( 13 - month( dArg )) 

 return LDoM( dDec )

 

function LDoM( dArg )

   local dNxtMonth 

   dNxtMonth = dArg - day( dArg ) + 45 

 return dNxtMonth - day( dNxtMonth )