Fixed datediff function