04-15-2010 12:35 PM
hi! all
How to add date and Time.
I'm having a date as - 15.04.2010 06:00:00and i need to add 6 hours to the date given.
thus i should get, 15.04.2010 06:00:00 + 06 hours = 15.04.2010 12:00:00; and
if the given date is 15.04.2010 22:00:00 + 06 hours = 16.04.2010 03:00:00.
how to add like this is there any function module available.
Regards,
Kv
04-15-2010 1:07 PM
04-15-2010 12:38 PM
Hi,
Why don;t u use TIME stamp Function modules
ALL FUNCTION 'RKE_TIMESTAMP_CONVERT_INPUT'
EXPORTING
i_date = v_datum
i_dayst = sy-dayst
i_time = v_uzeit
i_tzone = sy-tzone
IMPORTING
e_timestmp = ch_timestmp
EXCEPTIONS
date_invalid = 1
OTHERS = 2
Regards,
Pravin
04-15-2010 12:38 PM
Why don't you go with simple mathematical calculation instead of FM's. I suppose there isn't any such available.
If time GE '24:00:00'
date = date + 1.
else
time = time + 1.
endif.
04-15-2010 12:41 PM
Hi,
This can be dealt purely logical.
You have a date and time and you add another time to it while doing that,
check if by adding the 2 times you get a value more than 24 if yes increment the date by 1 day.
and (added time - 24) wil give the remaining time to be displayed with the new date
Eg: 15.04.2010 06:00:00 + 22:00:00 =
when You add 22 and 6 its 28. so its greater than 24 so merely change thwe date to the next one and make the tiem = 28 - 24 = 4
so You would have 16.04.2010 04:00:00 as the answer.
Hope this helps.
04-15-2010 12:47 PM
Hi,
If you add any number to the date field say
data w_date type sy-datum.
w_date = sy-datum.
w_date = w_date + 5.
then 5 days will be added to the present date.
data w_time type sy-timlo.
w_time = sy-timlo.
w_time = w_time + 5.
then five seconds will add to the present time.
Regards and Best wishes.
04-15-2010 1:07 PM
04-15-2010 2:03 PM
Hi I think there's a function module which can fulfill your requirements..
Please take the help of the FM:
C14B_ADD_TIME
Please revert back in case of any issues..
04-15-2010 3:40 PM
Am giving an example as to how the FM is to be used...
Hope this helps you...
data : xtra type T.
data : r_date type D.
data : s_date type D.
data : r_time type T.
data : s_time type T.
data : r_date1(10) type c.
s_date = '20100415'.
s_time = '060000'.
xtra = '220000'.
CALL FUNCTION 'C14B_ADD_TIME'
EXPORTING
i_starttime = s_time
i_startdate = s_date
i_addtime = xtra
IMPORTING
E_ENDTIME = r_time
E_ENDDATE = r_date
.
write : r_date dd/mm/yyyy to r_date1.
write : r_date1 .
write : r_time .
Please revert back in cse of any issues...
04-15-2010 4:49 PM
Basic date/time questions = FAQ = not allowed.
Please search before posting and don't reply to such questions!
Thread locked
Thomas