fixed sql date comparison to be pre-4.1 compatible