Simplify some of the date and time checks before adding to the date query.