Fix the condition of date comparing