this is going to be really, really, really slow.  You've broken them all down to millisecond values, is there a reason why you can't just do (timestamp >= startOfLastYearTimestamp && timestamp < endOfLastYearTimestamp)  ?