Informix Error -4081: Warning: A DATETIME expression cannot be negative.
Cause and resolution
Warning: A DATETIME expression cannot be negative.
A "-" operator occurred with a DATETIME operand. No negative points exist in time. INTERVAL can be negative, but DATETIME cannot. Inspect the syntax of the expression, and revise it to make it greater than or equal to zero.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4081 is a compiler warning: per the official guidance, a - operator was applied with a
DATETIME operand, but no negative points in time exist — INTERVAL can be negative,
DATETIME cannot.
- A
-operator producing a negativeDATETIMEresult, per the official guidance — the direct, only cause.
Solutions / Resolution
- Inspect the syntax of the expression, per the official guidance.
- Revise it to make the result greater than or equal to zero, per the official guidance.
Examples
A DATETIME expression going negative
DEFINE d DATETIME YEAR TO SECOND
LET d = TODAY - 100 UNITS DAY
-- -4081: if this pushes the DATETIME below its valid range
Corrected
LET d = TODAY - 10 UNITS DAY
Diagnostic Checks
- Check any
DATETIME-INTERVALsubtraction for the possibility of producing a negative/invalid result, and revise the expression.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -4081 in this set yet.
A DATETIME expression would go negative — revise it, since DATETIME can't represent
negative time (unlike INTERVAL).