MainframeKit

-181

SQLSTATE 22007NEGATIVE SQLCODE

A date, time or timestamp string was in a valid format but held an impossible value, such as month 13 or 31 April.

MOST LIKELY

A day that does not exist in the month (for example 2026-02-30).

FIRST CHECK

Display the value and check each part against the allowed ranges.

TRY IT ▸

MainframeKit assistant

What it means

The string looks like a datetime value, but at least one part is outside its allowed range. Years must be 0001 to 9999, months 1 to 12, days must exist in that month (29 February only in leap years), minutes and seconds 0 to 59, and fractional seconds up to six digits.

Hours can be 0 to 24 in most formats, or 0 to 12 in the USA format. Time zone hours are -12 to +14.

Typical causes

  • A day that does not exist in the month (for example 2026-02-30).
  • Day and month swapped (for example 2026-25-10).
  • A year of 0000, often from a zero-filled field.
  • An hour of 13 or more in a USA-format time.
  • Calculated dates that run past the end of a month.

How to fix it

  1. Display the value and check each part against the allowed ranges.
  2. Look for day/month swaps where data comes from another system.
  3. Validate dates in the program before the SQL call.
  4. Correct the value or the code that builds it, then rerun.

Example

Illustrative only; names and values are invented.

SQLCODE = -181, SQLSTATE = 22007
-- host variable WS-START-DATE = '2026-02-30'