Informix Error -1218: String to date conversion error.
Cause and resolution
String to date conversion error.
The input to the rstrdate() function does not properly represent a date: either it has nondigits where digits are expected, an unexpected delimiter, or numbers that are too large or are inconsistent.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-1218 fires when the input to rstrdate() doesn't properly represent a date — per the official
guidance, this covers non-digit characters where digits are expected, an unexpected delimiter, or
numbers that are too large or internally inconsistent (e.g. a day that doesn't fit its month).
- Non-digit characters in the input where digits are expected, per the official guidance — the direct, named cause.
- An unexpected delimiter in the input string, per the official guidance's other named cause.
- Numbers too large, or inconsistent with each other (e.g. day 31 for a 30-day month), per
the official guidance — the same underlying validity issues as -1204/-1205/-1206, surfaced
through
rstrdate()'s own parsing.
Solutions / Resolution
- Validate the input string's format before passing it to
rstrdate(), per the official guidance — check for non-digit characters, unexpected delimiters, and internally consistent month/day/year values.
Examples
Malformed input to rstrdate
int rc = rstrdate("13/45/2024", &date_val);
-- -1218: month 13 and day 45 are both invalid
Diagnostic Checks
- Inspect the exact input string passed to
rstrdate()for non-digit characters, unexpected delimiters, or an internally inconsistent month/day/year combination.
Related Errors / Related Topics
- -1204 — "Invalid year in date." A related date-validity error, in the general SQL date-
literal context rather than
rstrdate()specifically. - -1205 — "Invalid month in date." A related date-validity error.
- -1206 — "Invalid day in date." A related date-validity error.
- -1209 — "Without any delimiters, this date must contain exactly 6 or 8 digits." A related date-parsing error, about undelimited numeric dates specifically.
rstrdate()'s input string doesn't properly represent a date — check for non-digit characters,
unexpected delimiters, and internal month/day/year consistency.