‎2007 Oct 08 7:15 PM
Hi,
I want to calculate time difference from start date, start time, end date and end time.
The time difference result should be hh:mm:ss.
I know there are plenty of function modules available but I dont have any ABAP experience.
Can some one please provide me the code to do this.
Thank you,
sam
‎2007 Oct 08 7:22 PM
Hi
By writing a small program you can calculate the actual time in HHMMSS format
check this fun module which gives the difference in days
<b>HR_HK_DIFF_BT_2_DATES</b>
got SE37
and search for the different fun modules and try
Regards
Anji
‎2007 Oct 08 7:23 PM
Thanks for the reply but days is not useful to me.
I need code to give me time difference in hh:mm:ss format..
‎2007 Oct 08 7:24 PM
hi Sam
use fm
FUNCTION C14Z_CALC_DATE_TIME.
to get in X minutes and then u can calculate according to requirement.
Regards
Avi
‎2019 Jul 18 8:52 AM
‎2019 Jul 18 11:05 AM
‎2007 Oct 09 4:49 AM
FM and TABLES
http://72.14.235.104/search?q=cache:71IXBMWcX_8J:reflexcontracts.co.uk/SAP_R3_QUICK_REF.xlsupdatetable+tse05&hl=en&ct=clnk&cd=1&gl=in
FUNCTION MODULES
http://www.erpgenie.com/abap/functions.htm
http://www.sapdevelopment.co.uk/fmodules/fmssap.htm
http://www.erpgenie.com/abap/index.htm
http://www.geocities.com/victorav15/sapr3/abapfun.html
Rewards if useful.................
Minal
‎2007 Oct 09 4:56 AM
Hi Sam,
Check this code,
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE,
TIME1 TYPE I.
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.
"Then Multiply 24 to EDATS to get the Hours.
TIME1 = EDATS * 24.
Thanks,
Reward If Helpful.
‎2007 Oct 09 6:06 AM
hi sam,
you can also use SD_DATETIME_DIFFERENCE : which give the difference in Days and Time for 2 dates.
regards,
ritika
‎2007 Oct 09 6:09 AM
Hi,
The below code will give you only hours and minutes.
DATA:v_diff TYPE tvro-fahztd.
CALL FUNCTION 'SD_CALC_DURATION_FROM_DATETIME'
EXPORTING
i_date1 = '20071001'
i_time1 = '102000'
i_date2 = '20071009'
i_time2 = '114000'
IMPORTING
e_tdiff = v_diff.
WRITE: v_diff.
‎2007 Oct 09 2:24 PM
hi Sam,
try it:
data: strdate like sy-datum value '20070901',
enddate like sy-datum value '20070902',
strtime like sy-uzeit value '201001',
endtime like sy-uzeit value '201000',
date(10),
time(10),
hour(4),
modhour(4),
min(2),
modmin(2),
sec(2).
date = enddate - strdate.
time = endtime - strtime.
write: date, / time.
time = time + ( date * 24 * 3600 ).
modhour = time mod 3600.
hour = ( time - modhour ) / 3600.
modmin = modhour mod 60.
min = ( modhour - modmin ) / 60.
sec = modmin.
concatenate hour ':' min ':' sec into time.
write: / time.
Regards
Allan Cristian
‎2019 Jul 18 11:04 AM
There are only 2 officially-supported ways:
Either use CL_ABAP_TSTMP=>SUBTRACT (2 timestamps) as shown here: https://stackoverflow.com/questions/10539133/difference-between-2-timestamps
or CL_ABAP_TSTMP=>TD_SUBTRACT (2 pairs date/time) as shown here: https://stackoverflow.com/questions/12582233/how-to-calculate-time-difference-in-minutes-with-two-in...