MainframeKit

-180

SQLSTATE 22007NEGATIVE SQLCODE

A date, time or timestamp string had the wrong length or format, so Db2 could not read it as a datetime value.

MOST LIKELY

A host variable full of spaces or low-values passed as a date.

FIRST CHECK

Display the exact value being passed, including its length and hex content.

TRY IT ▸

MainframeKit assistant

What it means

Db2 accepts DATE, TIME and TIMESTAMP values as strings only in its recognised formats and lengths. When a value does not match any of them, the statement stops. The message shows the bad value, or tells you which host variable or column it came from.

-180 is about the format. If the format is right but a part is out of range, such as month 13, you get -181 instead.

Typical causes

  • A host variable full of spaces or low-values passed as a date.
  • A date built in the wrong layout, such as DD/MM/YYYY when the system expects another format.
  • Missing separators, or the wrong separator character.
  • A timestamp string that is too short or has too many fractional digits.
  • Uninitialised working storage moved into a date field.

How to fix it

  1. Display the exact value being passed, including its length and hex content.
  2. Compare it with the formats Db2 accepts (ISO YYYY-MM-DD is safe) and the DATE/TIME settings in use.
  3. Initialise date fields to a valid default, or use an indicator variable to pass null.
  4. Fix how the program builds the string, then rerun.

Example

Illustrative only; names and values are invented.

SQLCODE = -180, SQLSTATE = 22007
THE DATE, TIME, OR TIMESTAMP VALUE '2026/10/26' IS INVALID