fix SQL error with date field when using this condition, RT#7218