Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Date and Time Processing →  Character-Like Date Fields and Time Fields 

Validity of Character-Like Date Fields and Time Fields

Character-like date fields and time fields of the types d and t can contain any alphanumeric characters.

  • Valid values for the type d, however, are only those digits that are valid dates according to the calendar rules in the format "yyyymmdd": "yyyy" (year): 0001 to 9999, "mm" (month): 01 to 12, "dd" (day): 01 to 31.
  • Valid values for the type t, however, are only those digits that are interpreted as times in the 24-hour clock format "hhmmss". "hh" (hours): 00 to 23, "mm" (minutes): 00 bis 59, "ss" (seconds): 00 to 59.

The ABAP runtime environment checks the validity at the following points:

  • Character-like date fields and time fields with invalid values raise an exception as a source field of the statement MOVE EXACT. Conversely, source fields of other types may not produce any invalid values in character-like date fields and time fields as target fields for MOVE EXACT.
  • In a regular assignment to numeric fields, character-like date fields and target fields with invalid values produce the value 0, with the following exceptions:
  • For a source field of the type d, the values from 5.10.1582 to 14.10.1582, which are actually invalid due to the conversion from the Julian to Gregorian calendar, are handled just like the valid values from 15.10.1582 to 24.10.1582.
  • For a source field of the type t that contains only digits, the numeric value is calculated using the formula hh*3600+mm*60+ss, even if the times are invalid.
  • For regular assignments of numeric fields to character-like date fields and time fields, the numeric fields must be within the value range of the data type i and comply with the following special rules:
  • When numeric values are assigned to character-like date fields, and these fields cannot be produced by the reverse conversion, then the date field is initialized
  • Any numeric values can be assigned to character-like time fields. When converted, the numeric value is divided by 86400 and only the integer remainder of the division is considered. This always produces a valid time in hours,

No checks are generally made on other assignments to character-like date fields and time fields not mapped to assignments of of numeric values, nor to other operand positions. As a consequence, invalid values are produced easily by character-like date fields and time fields, and then processed further.

Other versions: 7.31 | 7.40 | 7.54

Initial Value of Character-Like Date Fields

The initial value "00000000" of the data type d and the date 01.01.0001 have a special part to play here.

  • The initial value "00000000" of data type d is not a valid date. A conversion of the initial value "00000000" to a numeric data type produces, like all invalid values, the value 0. Conversely, the conversion of the number 0 to a date field of the type d always produces the invalid date "00000000". Negative and oversized numbers also produce the invalid date "00000000".
  • A conversion of a valid date to a field of the type d produces the number of days since 01.01.0001, which makes this date the zero point for date calculations. A conversion of a date field of the type d with the value "00010101" to a numeric value produces the value 0, like the conversion of the initial value or any other invalid value, and the conversion cannot be reversed.

1 is the smallest number that is converted to a valid date, 02.01.0001, when assigning to a date field of type d. Assignments between valid character-like date fields and numeric fields can be reversed only from this date.

In the statement MOVE EXACT, assignments of invalid values do not produce the value 0 or "00000000" but raise exceptions instead. Here, the value "00010101", which is really part of the value range, is considered as invalid, while "00000000", not actually part of the value range, is considered to be valid. This means that the initial value "00000000" can be used by MOVE EXACT and all valid assignments between character-like date fields and numeric fields can be reversed.


Note

The validity of the content of character-like date fields and time fields must be verified before they are accessed.