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
612

Hi,

I have three variables which store yyyy, mm and dd (and all are of C type). Now I want all of this into one variable which is of the format sy-datum so that I will be able to compare this with sy-datum.

(like if wa_datum LE sy-datum, perform this etc)

Can you tell me how you do that?

Thanks,

Krishen

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
585

hi Krishen,

Use Concatenate statement ..

i.e, concatenate f1 f2 f3 into f4.

Regards,

Santosh

5 REPLIES 5
Read only

Former Member
0 Likes
585

Hi,

DATA: v_date type sydatum.

Concatenate 'YYYY' 'MM' 'DD' INTO V_DATE.

Ex.

data: v_date type sydatum.

concatenate '2006' '09' '20' into v_date.

if v_date < sy-datum.

write: / v_date.

endif.

THanks

Naren

Read only

Former Member
0 Likes
586

hi Krishen,

Use Concatenate statement ..

i.e, concatenate f1 f2 f3 into f4.

Regards,

Santosh

Read only

Former Member
0 Likes
585

concatenate yyyy mm dd into ldate.

ldate is of type sy-datum.

Read only

ferry_lianto
Active Contributor
0 Likes
585

Hi,

You can try something like this.


DATA: WA_DATUM LIKE SY-DATUM.

MOVE V_YYYY TO WA_DATUM(4).
MOVE V_MM   TO WA_DATUM+4(2).
MOVE V_DD   TO WA_DATUM+6(2).

IF WA_DATUM LE SY-DATUM.
  ...
ELSE.
  ...
ENDIF.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
585

Declare a variable of type sy-datum. And pass the value to that variable and compare.

For example:

data: ws_date type char10.

data: ws_date1 type sy-datum,

ws_date2 type sy-datum.

ws_date = '2006.01.01'.

concatenate ws_date0(4) ws_date4(2) ws_date+6(2) into ws_date1.

ws_date2 = '20060101'.

if ws_date1 eq ws_date2.

*do sum operation

endif.