Fix datediff bug