Informix Error -1261: Too many digits in the first field of datetime or interval.
Cause and resolution
Too many digits in the first field of datetime or interval.
The first field of a DATETIME literal must contain either 1 or 2 digits (if it is not a YEAR) or else 2 or 4 digits (if it is a YEAR). The first field of an INTERVAL literal represents a count of units and can have up to 9 digits, depending on the precision that is specified in its qualifier. Review the DATETIME and INTERVAL literals in this statement, and correct them.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-1261 fires when a DATETIME or INTERVAL literal's first field has more digits than allowed —
per the official guidance, DATETIME fields take 1-2 digits (2 or 4 digits for YEAR
specifically), while INTERVAL fields can take up to 9 digits depending on the qualifier's
precision.
- A
DATETIMEliteral's first field exceeding its 1-2 (or 2/4-digit forYEAR) limit, per the official guidance — the direct, common cause. - An
INTERVALliteral's first field exceeding the digit count its qualifier's precision allows, per the official guidance's other named case.
Solutions / Resolution
- Review and correct the formatting of the
DATETIME/INTERVALliteral, per the official guidance, matching the digit count to the field type and qualifier precision.
Examples
A YEAR TO MONTH interval with too many digits
SELECT INTERVAL(123456) YEAR(4) TO MONTH FROM orders WHERE order_id = 1;
-- -1261: 123456 exceeds the 4-digit precision specified for the YEAR field
Corrected
SELECT INTERVAL(1234-06) YEAR(4) TO MONTH FROM orders WHERE order_id = 1;
Diagnostic Checks
- Check the digit count of the literal's first field against the field type's limit
(
DATETIME) or the qualifier's declared precision (INTERVAL).
Related Errors / Related Topics
- -1262 — "Non-numeric character in datetime or interval." A related literal-formatting error, about invalid characters rather than digit count.
- -1263 — "A field in a datetime or interval is out of range, incorrect, or missing." A related literal-validity error, about a field's value rather than its digit count.
- -1264 — "Extra characters at the end of a datetime or interval." A related literal- formatting error, about trailing characters.
The literal's first field has more digits than its type/precision allows — correct the formatting.