Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

date calculation

Former Member
0 Likes
593

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
533

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

1 REPLY 1
Read only

Former Member
0 Likes
534

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