Learn it on Mainframe Path. Do it with Mainframe KIT.Learn on Mainframe Path ▸
Mainframe KIT ● Nothing leaves this tab

-181

Datetime string not validNEGATIVE SQLCODE · CHECKED 2026-11-14
Checked against IBM documentation

The string form of a datetime value is out of range or in the wrong format. IBM's page lists the allowed ranges.

QUICK ANSWER

The string form of a datetime value is out of range or in the wrong format. IBM's page lists the allowed ranges.

LIKELY CAUSES, IN THE ORDER OF THIS ENTRY

  1. A month, day, hour, minute or second is outside its valid range.
  2. A February day is 29 in a non-leap year, or a day is 31 in a 30-day month.
  3. The string is not in a correct format.

CHECKED 14 Nov 2026 IBM: Db2 13 for z/OS: SQLCODE -181 (Db2 for z/OS 13.0.0)

MOST LIKELY

A month, day, hour, minute or second is outside its valid range.

FIRST CHECK

Check that each part of the value is within the documented range.

TRY IT ▸

Site search

What it means

The string is not in the acceptable range or format. IBM gives ranges: years 0001-9999, months 1-12, days 1-28/29/30/31 by month, minutes and seconds 0-59, fractional seconds 0-999999. SQLSTATE is 22007.

Hours are 0-12 for the USA format and 0-24 for other predefined formats; when the hour is 24 in a non-USA format, the other time parts are zeros.

Typical causes

  • A month, day, hour, minute or second is outside its valid range.
  • A February day is 29 in a non-leap year, or a day is 31 in a 30-day month.
  • The string is not in a correct format.

How to fix it

  1. Check that each part of the value is within the documented range.
  2. Correct the syntax and reissue the statement.