Application Development 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: 

Adding

Former Member
1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Syed,

u can simply add one to time and it will be incremented by one second.

data ztime type sy-uzeit.

ztime = sy-uzeit.

ztime = ztime + 1.

Regards,

Pankaj

6 REPLIES 6

Former Member
0 Kudos

Well, the easiest thing to do is to simply add a number (of days) to a date.

data: w_date like sy-datum.

w_date = sy-datum.

w_date = w_date + 90.

  • w_date has a date 90 days in the future.

But if you have to add months or years, you can use FM RP_CALC_DATE_IN_INTERVAL:

data: w_date like sy-datum.

data: new_date like sy-datum.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

DATE = w_date

DAYS = 0

MONTHS = 3

SIGNUM = '+'

YEARS = 0

IMPORTING

CALC_DATE = new_date

EXCEPTIONS

OTHERS = 1.

  • new_date has a value 3 months in the future.

You can use combinations of days, months and years.

Rob

Also bear in mind that unlike ordinary arithmetic, the order of operation is important in date arithmetic. Adding a certain number of days to a date and then some months doesn't always give the same answer if you do it the other way around:

2005/02/28 + 1 day + 3 months = 2005/06/01

2005/02/28 + 3 months + 1 day = 2005/05/29

Former Member
0 Kudos

Hi Syed,

u can simply add one to time and it will be incremented by one second.

data ztime type sy-uzeit.

ztime = sy-uzeit.

ztime = ztime + 1.

Regards,

Pankaj

0 Kudos

Hi pankaj ,

Thanks 4 ur reply, i can add second to time but it shld effect to my date also.

Please help me.

Thanks,

SB.

0 Kudos

Hi Sayed,

For this you need to hard code ....

there wil be inly one case where you need to increment your date by when and that is when the time is 23:59 hrs and after increment it will be 00:00 hrs.

IF ZTIME = '000000'

increment date by one ... jst add one the same way we did for time

endif.

Regards,

Pankaj Sharma

Former Member
0 Kudos

Hi Syed,

Check this function module 'C14B_ADD_TIME' . Hope this helps you.

Former Member
0 Kudos

Hi ,

Backend time will store in HH:MM:SS format

so take this time to one variable.

here is the example :

time = hh:mm:ss

time6(2) = time6(2) + 1.

Reward if useful...

Varma