It would be a little clearer to have one test for year and then do the sql append, the date calculations and the parameter setting.