# pydantic_core._pydantic_core.ValidationError: 1 validation error for Event
when
  Input should be a valid datetime, invalid date separator, expected `-` [type=datetime_parsing, input_value='2024/01/15', input_type=str]

- **ID:** `python/pydantic-datetime-parsing`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The string uses slash separators that Pydantic v2's strict ISO parser rejects. It expects ISO 8601 with dashes.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   from pydantic import BaseModel, field_validator
from dateutil import parser
class Event(BaseModel):
    when: 'datetime'
    @field_validator('when', mode='before')
    @classmethod
    def parse(cls, v):
        return parser.parse(v) if isinstance(v, str) else v
   ```
2. **** (85% success)
   ```
   import re
s = re.sub(r'/', '-', '2024/01/15')
Event(when=s)
   ```

## Dead Ends

- **** — datetime_format only applies to date fields, not datetime, and won't accept time-less strings. (50% fail)
- **** — Loses validation; downstream code must branch on type. (60% fail)
- **** — Every call site must remember to convert; easy to miss and inconsistent. (45% fail)
