‎2007 Feb 17 1:52 PM
Could someone explain me the following from the code below:-
q1]] How do we get "80049488" in the 1st output?
q2]] why there is no difference between the outputs in the 3rd & 4th cases?:
q3]] what is the possible answer to the question "Inverted Dates"?
-
Inverted Dates
In some cases (for example, when sorting dates in descending order), it is useful to convert a
date from format D to an inverted date by using the keyword CONVERT
CONVERT DATE <d1> INTO INVERTED-DATE <d2>.
Afterwards, you can convert the inverted data back into a normal date using the statement
CONVERT INVERTED-DATE <d1> INTO DATE <d2>.
These statements convert the field <d1> from the formats DATE or INVERTED-DATE to the
formats INVERTED-DATE or DATE and assign it to the field <d2>.
For the conversion, ABAP forms the nine's complement.
DATA: ODATE TYPE D VALUE '19955011',
IDATE LIKE ODATE.
DATA FIELD(8).
FIELD = ODATE. WRITE / FIELD.
CONVERT DATE ODATE INTO INVERTED-DATE IDATE.
FIELD = IDATE. WRITE / FIELD.
CONVERT INVERTED-DATE IDATE INTO DATE ODATE.
FIELD = ODATE. WRITE / FIELD.
Output:
80049488
19955011
1995501
‎2007 Feb 17 5:52 PM
Hi,
I am not sure if the output mentioned by you is correct. I got the followed the same code and got the following output:
19955011
80044988
19955011
The principle is simple as you would already have discovered,
inversion 1 = 99999999 - date
back = 99999999 - date
Hope this helps.
Cheers,
~i1
‎2007 Feb 17 5:52 PM
Hi,
I am not sure if the output mentioned by you is correct. I got the followed the same code and got the following output:
19955011
80044988
19955011
The principle is simple as you would already have discovered,
inversion 1 = 99999999 - date
back = 99999999 - date
Hope this helps.
Cheers,
~i1