Informix Error -1267: The result of a datetime computation is out of range.
Cause and resolution
The result of a datetime computation is out of range.
In this statement, a DATETIME computation produced a value that cannot be stored. This situation can occur, for example, if a large interval is added to a DATETIME value. This error can also occur if the resultant date does not exist, such as Feb 29, 1999.
Review the expressions in the statement and see if you can change the sequence of operations to avoid the overflow.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-1267 fires when a DATETIME computation produces a value that can't be stored — per the
official guidance, common scenarios include adding a large INTERVAL to a DATETIME value, or
the resulting date simply not existing (the official guidance's own example: February 29 in a
non-leap year).
- Adding a large
INTERVALto aDATETIMEvalue, per the official guidance's named scenario, pushing the result out of the valid range. - A computation landing on a date that doesn't exist, per the official guidance's specific example — February 29 in a non-leap year.
Solutions / Resolution
- Review the expressions in the statement, per the official guidance.
- Modify the sequence of operations to prevent the overflow, per the official guidance — reordering or validating intermediate results can avoid landing on an invalid date.
Examples
Landing on a nonexistent date
SELECT DATETIME(2000-02-29) YEAR TO DAY + INTERVAL(1) YEAR TO YEAR FROM orders WHERE order_id = 1;
-- -1267: adding 1 year to Feb 29, 2000 (a leap year) would land on
-- Feb 29, 2001 — but 2001 is not a leap year, so that date doesn't exist
Diagnostic Checks
- Trace the computation step by step to identify which intermediate or final result lands outside the valid range or on a nonexistent date.
Related Errors / Related Topics
- -1265 — "Overflow occurred on a datetime or interval operation." A related
DATETIMEarithmetic error, about an internalDECIMALoverflow rather than the resulting date being invalid. - -1266 — "Intervals or Datetimes are incompatible for the operation." A related
DATETIME/INTERVALarithmetic error, about an unsupported operand combination.
The computation produced an out-of-range or nonexistent date — review and reorder the operations involved.