Informix Error -2856: The TODAY attribute may be assigned only to date columns.
Cause and resolution
The TODAY attribute may be assigned only to date columns.
The TODAY function (not attribute) returns the value of today's date. That value can be assigned only to a field that has the DATE or DATETIME data type. The field in this statement has a different type. Automatic data conversion is provided in 4GL programs, but not in the context of a form.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-2856 fires when the TODAY attribute is assigned to a field that isn't DATE/DATETIME —
per the official guidance, TODAY returns the current date, so it can only apply to date-typed
fields; unlike 4GL programs (which support automatic conversion), forms don't convert it for
other types.
TODAYassigned to a non-DATE/DATETIMEfield, per the official guidance — the direct, only cause.
Solutions / Resolution
- Assign
TODAYonly toDATE/DATETIMEfields, per the official guidance — forms don't perform the automatic conversion 4GL programs do.
Examples
TODAY on a non-date field
ATTRIBUTES
status = order_status, DEFAULT = TODAY;
-- -2856: order_status is CHAR, not DATE/DATETIME
Corrected
ATTRIBUTES
order_date = order_date, DEFAULT = TODAY;
Diagnostic Checks
- Check the declared type of any field assigned
TODAY, and confirm it'sDATE/DATETIME.
Related Errors / Related Topics
- -2867 — "The CURRENT attribute may be assigned only to datetime columns." The same
no-auto-conversion rule applied to
CURRENT/DATETIMEinstead ofTODAY/DATE.
TODAY was assigned to a non-date field — forms don't auto-convert it, unlike 4GL programs.