OpenBB-finance/OpenBB · error · OpenBBError
Invalid date format. Please use '2024-03-08T12:15-0400'.
Error message
Invalid date format. Please use '2024-03-08T12:15-0400'.
What it means
OpenBBError raised during market_snapshots transform_query when the supplied date string cannot be parsed by datetime.fromisoformat after str() coercion. The provider expects an ISO-8601 datetime like '2024-03-08T12:15-0400' and tells you so; any non-ISO format (slashes, month names, missing timezone) triggers this before any request is made.
Source
Thrown at openbb_platform/providers/intrinio/openbb_intrinio/models/market_snapshots.py:124
dt = transformed_params["date"] # type: ignore
if isinstance(dt, dateType):
dt = datetime(
dt.year,
dt.month,
dt.day,
20,
0,
0,
0,
tzinfo=timezone("America/New_York"),
)
if isinstance(transformed_params["date"], str):
dt = datetime.fromisoformat(transformed_params["date"])
else:
try:
dt = datetime.fromisoformat(str(transformed_params["date"])) # type: ignore
except ValueError as exc:
raise OpenBBError(
"Invalid date format. Please use '2024-03-08T12:15-0400'."
) from exc
transformed_params["date"] = (
dt.strftime("%Y-%m-%dT%H:%M:%S.%f%z")
.replace("+", "-")
.replace("T00:", "T20:")
if isinstance(dt, datetime)
else dt
)
return IntrinioMarketSnapshotsQueryParams(**transformed_params)
@staticmethod
async def aextract_data(
query: IntrinioMarketSnapshotsQueryParams,
credentials: dict[str, str] | None,
**kwargs: Any,
) -> list[dict]:View on GitHub (pinned to 3e071fcc2c)
Solutions
- Pass the date as ISO-8601 with timezone offset, e.g. '2024-03-08T12:15-0400'.
- Normalize upstream: dt.isoformat() or datetime.strptime(raw, YOUR_FORMAT).isoformat() before the call.
- Or omit date to use the fetcher's default (most recent snapshot).
Example fix
# before
obb.equity.market.snapshots(provider='intrinio', date='03/08/2024')
# after
from datetime import datetime
date = datetime.strptime('03/08/2024', '%m/%d/%Y').isoformat()
obb.equity.market.snapshots(provider='intrinio', date=date) Defensive patterns
Strategy: validation
Validate before calling
from datetime import datetime
def to_intrinio_snapshot_date(raw: str) -> str:
for fmt in ('%Y-%m-%dT%H:%M%z', '%m/%d/%Y', '%Y-%m-%d'):
try:
return datetime.strptime(raw, fmt).isoformat()
except ValueError:
continue
raise ValueError(f"unrecognized date format: {raw!r}; use '2024-03-08T12:15-0400'") Type guard
from datetime import datetime
def is_iso_datetime(s: str) -> bool:
try:
datetime.fromisoformat(str(s))
return True
except ValueError:
return False Try / catch
from openBB_core.provider.exceptions import OpenBBError # noqa - correct: openbb_core
try:
res = obb.equity.market.snapshots(provider='intrinio', date=date_str)
except OpenBBError as e:
if 'Invalid date format' in str(e):
date_str = datetime.strptime(date_str, '%m/%d/%Y').isoformat()
res = obb.equity.market.snapshots(provider='intrinio', date=date_str)
else:
raise Prevention
- Always emit dates via datetime.isoformat()
- Never pass US MM/DD/YYYY strings directly
- Centralize date normalization at the edge of your app
- Omit date to use the default latest snapshot when exact time is unimportant
When it happens
Trigger: equity/market/snapshots with provider='intrinio' and date='03/08/2024', 'March 8 2024', '2024-03-08 12:15' (space instead of T), or similar non-ISO strings; the ValueError from fromisoformat is caught and converted to OpenBBError.
Common situations: Dates coming from user input or other systems (US format MM/DD/YYYY), pandas Timestamps serialized with spaces, or date strings accepted by other providers but not ISO here.
Related errors
- Required field missing -> symbol
- Period '{query.period}' not supported.
- Period '{query.period}' not supported.
- Unsupported file format. Please use .json or .env files.
- Failed to get Jupyter URL
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/9e28591a8e041060.
Report an issue: GitHub.