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

Calculating Data + time

Former Member
0 Likes
1,131

Hi all,

I have a small Question. I need to add the time to the date. for example

if we take todays date ie 02.05.2007 and add 24 hours then the output should be

03.05.2007. if we add 48 hours then the output should be 04.05.2007.

Is there any function module to do this.

Please Give some solution.

Ranjith

7 REPLIES 7
Read only

Former Member
0 Likes
943

use fm ADD _ TIME _ TO _ DATE

or

check this link for more info...

regds,

kiran

Read only

rahulkavuri
Active Contributor
0 Likes
943

https://forums.sdn.sap.com/click.jspa?searchID=1030563&messageID=2917434

check this example, u can use FM 'CATT_ADD_TO_TIME'

FM C14B_ADD_TIME

check its use from

https://forums.sdn.sap.com/click.jspa?searchID=1030563&messageID=1520791

dont forget to award points if found helpful

Read only

Former Member
0 Likes
943

use...

CATT_ADD_TO_TIME..

U need to sepecify the time in hours.

Read only

Former Member
0 Likes
943

use fm CATT_ADD_TO_TIME

give field STDAZ = (no.of hours you want to add)

regds,

kiran

Read only

Former Member
0 Likes
943

Please check the following code

DATA: start_date TYPE begda,

start_time TYPE begti,

add_value TYPE thour,

get_date TYPE begda,

get_time TYPE begti.

start_date = '20040706'.

start_time = '2300'.

add_value = '5.5'.

CALL FUNCTION 'CATT_ADD_TO_TIME'

EXPORTING

idate = start_date

itime = start_time

stdaz = add_value

IMPORTING

edate = get_date

etime = get_time

Read only

Former Member
0 Likes
943

Hi Ranjith,

Use fucntion module <b>CATT_ADD_TO_TIME</b> to add time to a date.

Give Start time to IDATE, Start time to ITIME and no of hours to STDAZ then it will gives you the corresponding date in EDATE and the time in ETIME.

data:

v_date type sy-datum,

v_time type sy-uzeit.

CALL FUNCTION 'CATT_ADD_TO_TIME'

EXPORTING

idate = sy-datum ->Start date

itime = '000000' ->Start time

stdaz = '43' ->Add time in no of hours

IMPORTING

EDATE = v_date ->End date

ETIME = v_time. ->End time

write:/ v_date, v_time.

Thanks,

Vinay

Read only

ferry_lianto
Active Contributor
0 Likes
943

Hi,

You can also use this FM RP_CALC_DATE_IN_INTERVAL.


call function 'RP_CALC_DATE_IN_INTERVAL'
  exporting
    date = sy-datum
    days = 2                <--- 48 hours
    months = 0
    signum = '+'
    years = 0
  importing
    calc_date = wa_date.

Regards,

Ferry Lianto