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
944

hi guys

I have to calculate date like this

dat1 = 20070706.

date2 = dat1 + 365 * 5.5.

So i would like to know in date2 field do I get 5.5yrs later date?

10 REPLIES 10
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
908



report zrich_0001.

data: datum2 type sy-datum.
data: datum1 type sy-datum value '20070706'.


call function 'RE_ADD_MONTH_TO_DATE'
     exporting
          months  = '66'  "<-- 5.5 years
          olddate = datum1
     importing
          newdate = datum2.

write:/ datum2.

Regards,

Rich Heilman

Read only

sreenivasa_reddy1
Participant
0 Likes
908

Use the FM /SAPHT/DRM_CALC_DATE

parameters:

date: date1

months:06

sign:+ (for future)

- (for back )

years:05

Award points if its useful.

Regards'

Sreenivas

Read only

Former Member
0 Likes
908

You can also use <b>RP_CALC_DATE_IN_INTERVAL</b> You can add days, months or years -:)

Greetings,

Blag.

Read only

Former Member
0 Likes
908

Hi,

Try like this:

REPORT ZDATEDIFF.

DATA: EDAYS LIKE VTBBEWE-ATAGE,

EMONTHS LIKE VTBBEWE-ATAGE,

EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = FROMDATE

i_date_to = TODATE

  • I_FLG_SEPARATE = ' '

IMPORTING

E_DAYS = EDAYS

E_MONTHS = EMONTHS

E_YEARS = EYEARS.

WRITE:/ 'Difference in Days ', EDAYS.

WRITE:/ 'Difference in Months ', EMONTHS.

WRITE:/ 'Difference in Years ', EYEARS.

INITIALIZATION.

FROMDATE = SY-DATUM - 60.

REgards,

Bhaskar

Read only

Former Member
0 Likes
908

Hello,

Do like this.

Parameters: date like sy-datum.

data: lv_datum like sy-datum.
data: int1 type p decimals 2.

int1 = 365 * 5.5

lv_datum = int1 + date.

write: lv_datum.

VAsanth

Read only

Former Member
0 Likes
908

Or Simply:


DATA: lv_date TYPE datum VALUE '20070101',
      lv_nb_days TYPE i.

lv_nb_days = 365 * '5.5'.
lv_date1 = lv_date1 + lv_nb_days.

WRITE: / lv_date1.

Read only

rodrigo_paisante3
Active Contributor
0 Likes
908

data d1 like sy-datum.

d1 = '20070706'.

d1 = d1 + 365 * 5 + 365 div 2.

write d1.

Read only

Former Member
0 Likes
908

HI,

here 5.5 years means 11/2 years so do like this.

data:dat1 type sy-datum,date2 type sy-datum.

dat1 = sy-datum.

write:/ dat1.

date2 = dat1 + 365 * 11 / 2.

write:/ date2.

rgds,

bharat.

Read only

Former Member
0 Likes
908
REPORT ychatest.

DATA : v_date LIKE p0001-begda.

v_date = sy-datum.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date      = v_date
    days      = '00'
    months    = '06'
    signum    = '+'
    years     = '05'
  IMPORTING
    calc_date = v_date.

WRITE : v_date.
Read only

Former Member
0 Likes
908

answers which I have got they are really helpful for me.

Thank You for all...