CONVERT DATE / INVERTED-DATE

CONVERT - Conversion of date specifications

Variants:

1. CONVERT DATE f1 INTO INVERTED-DATE f2.
2. CONVERT INVERTED-DATE f1 INTO DATE f2.

Effect

Calculates the nine's complement of the internal date format (YYYYMMDD - for more information about internal display, meaning and initial values of types, see TYPES) and places it in the field f2 . For example, 19950511 ==> 80049488 / 80049488 ==> 19950511.
In the inverse date format, the most recent date has the numerically smallest value. You can make use of this effect when sorting dates.

Note

The technique of manipulating the sort sequence of dates by inverting the internal date format is used only in very rare cases. You can sort internal tables in order of ascending or descending date values much more elegantly with the additions ... ASCENDING or ... DESCENDING of the SORT statement.

Example

DATA DATE_INV LIKE SY-DATUM. 
CONVERT DATE SY-DATUM INTO INVERTED-DATE DATE_INV.

Suppose, for example, SY-DATUM contains the date 11.05.1995 in its internal format 19950511. After execution of the CONVERT statement, DATE_INV would contain the internal format 80049488.