Datetime comparison error fixed