Start of change

-181   THE STRING REPRESENTATION OF A DATETIME VALUE IS NOT A VALID DATETIME VALUE

Explanation

The string representation of a datetime is not in the acceptable range or is not in the correct format. The proper ranges for datetime values are as follows:

Table 1. Range of datetime values
Datetime Specific Cases Numeric Range
Years   0001 to 9999
Months   1 to 12
Days For months:
  • April (month 4)
  • June (6)
  • September (9)
  • November (11)
1 to 30
For February (month 2) 1 to 28 (Years other than leap years.)
1 to 29 (Leap years only.)
For months:
  • January (month 1)
  • March (3)
  • May (5)
  • July (7)
  • August (8)
  • October (10)
  • December (12)
1 to 31
Hours If the format for hours is USA 0 to 12
For all other predefined formats 0 to 24
Minutes 1   0 to 59
Seconds 1   0 to 59
Fractional seconds 1   0 to 999999
Time zone hours   -12 to 14
Time zone minutes   0 to 59
Note:
  1. When the hour format is not USA and the value of the hour is 24, other parts of time values are zeros.

System action

The statement cannot be processed.

Programmer response

Check whether the value is within the valid range and is in the proper format. Correct the syntax, and reissue the statement.

SQLSTATE

22007

End of change