PostgreSQL error code
PostgreSQL error 22031
22031 is the SQLSTATE PostgreSQL reports for invalid argument for sql json datetime function, in class 22, Data Exception.
| SQLSTATE | 22031 |
|---|---|
| Condition name | invalid_argument_for_sql_json_datetime_function |
| Class | 22 — Data Exception |
Reproduce it, then fix it
Without a template, .datetime() only knows ISO-style formats. Pass the format the string uses. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
SELECT jsonb_path_query('"12/31/2024"', '$.datetime()');SELECT jsonb_path_query('"12/31/2024"', '$.datetime("MM/DD/YYYY")');