Cast a value to a DateTime