Apply year and quarter to query