OutOfBoundsDatetime: Out of bounds nanosecond timestamp - How to Fix it
Answer
This error means your date is outside pandas' supported range (1677 to 2262). Fix it by using errors='coerce' to convert invalid dates to NaT, or switch to object dtype if you need to preserve dates outside that range.
Why This Happens
Pandas stores datetimes as nanoseconds since 1970, using a 64-bit integer. This limits the range to approximately 1677-09-21 to 2262-04-11. Dates outside this range โ like year 9999 for "never expires" or historical dates before 1677 โ can't be represented and raise this error.
Solution
The rule: if your data might contain dates before 1677 or after 2262, always use errors='coerce' or keep as strings.
import pandas as pd
# โ Problematic: date outside pandas range
df = pd.DataFrame({'date': ['2020-01-01', '9999-12-31']})
df['date'] = pd.to_datetime(df['date'])
# OutOfBoundsDatetime: Out of bounds nanosecond timestamp
# โ
Fixed: coerce invalid dates to NaT
df['date'] = pd.to_datetime(df['date'], errors='coerce')
# 9999-12-31 becomes NaT
# โ
Fixed: keep as string if you need the original values
df['date_str'] = df['date'].astype(str) # preserve for display
df['date_parsed'] = pd.to_datetime(df['date'], errors='coerce') # parse what you can
# โ
Alternative: use datetime.datetime for out-of-range dates
from datetime import datetime
# Store as object dtype, handle manuallyBetter Workflow
Zerve lets you inspect column values inline before parsing, so you can spot outlier dates like 9999-12-31 before they break your datetime conversion.
)
&w=1200&q=75)
&w=1200&q=75)
&w=1200&q=75)