Correct calculation of expiry date used in query to be in past, not future.