‎2009 Sep 14 6:12 AM
Hello All,
i have the requiremnt like this,,
i have beging time and endtime i need to get the totla working time by subtracting those 2 times,but the problem is in the table catsdb there is a filed called catshours which is the difference between the two timings,but the problem is that for a time 10hours 12 mins its showing as 9.72 mins like that,my req is that ineed to get the time excattly as 10hours 12 mins,for that what i did is i manually subtracted begiin time from end time but still its not giveing me the excatt time difference,
For EX: begin time : 08.40
endtime : 20.45pm
the differnece is 43380
but its giveing me 43500
can any one pls solve me this,,,,,
‎2009 Sep 14 6:18 AM
>
> For EX: begin time : 08.40
> endtime : 20.45pm
> the differnece is 43380
> but its giveing me 43500
> can any one pls solve me this,,,,,
how are you calculating???
20:45:00 - 08:40:00 = 12:05:00 "how are you saying it as 43380??data : d1 type sy-uzeit,
d2 type sy-uzeit, d3 TYPE sy-uzeit.
d1 = '084000'.
d2 = '204500'.
d3 = d2 - d1.
WRITE : d2, ' - ', d1,' = ',d3.
‎2009 Sep 14 6:44 AM
if u mulitply it with 3600 that is
20.45*60 = 1227
08.40*60 = 504
then 1227-504 = 723
723*60 = 43380
in this way iam doing
‎2009 Sep 14 6:48 AM
use a std function module which will take of the time differences based on regions also.. ur calculations might not be perfect...
use some FMs like [DELTA_TIME_DAY_HOUR|http://blog.chinaunix.net/u1/40527/showart.php?id=316843]
‎2009 Sep 14 7:47 AM
>
> if u mulitply it with 3600 that is
>
> 20.45*60 = 1227
> 08.40*60 = 504
>
> then 1227-504 = 723
> 723*60 = 43380
> in this way iam doing
dharani, you might be doing a wrong calculation
20Hr 45 Min is not the same as 20.45 hours. (decimal is for 100th division and time is 60th division)
20hr 45min = 20*60 + 45 = 1245 min
8hr 40 min = 8*60 + 40 = 520 min
1245 - 520 = 725 min
725 * 60 = 43500 secs (not 43380)
‎2009 Sep 14 8:04 AM
Hii
wat u said is excattly right now i got it, but how can i get the excat the time difference,eventhoug i am doing the same as per u but iam unable to get the excatt value
‎2009 Sep 14 8:05 AM
i have created a demo code for you.
check this out.
data : d1 type sy-uzeit,
d2 type sy-uzeit, d3 TYPE sy-uzeit, l1 TYPE MCWM_LZEIT, l2 TYPE MCWMIT-BE_AE.
d1 = '084000'.
d2 = '204500'.
d3 = d2 - d1.
CALL FUNCTION 'L_MC_TIME_DIFFERENCE'
EXPORTING
date_from = sy-datum
date_to = sy-datum
TIME_FROM = d1
TIME_TO = d2
IMPORTING
DELTA_TIME = l2
DELTA_UNIT = l1
EXCEPTIONS
FROM_GREATER_TO = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
data : xya type i.
xya = l2 * 60.
WRITE : d2, ' - ', d1,' = ',d3, ' exact:',l2, l1, ' = ', xya.
‎2009 Sep 14 8:36 AM
Hi,
You can also use the FM 'SCOV_TIME_DIFF' to find the time difference.
CLEAR : lv_days,lv_time.
CALL FUNCTION 'SCOV_TIME_DIFF'
EXPORTING
im_date1 = Start date
im_date2 = End date
im_time1 = start time
im_time2 = end time
IMPORTING
ex_days = lv_days
ex_time = lv_time
EXCEPTIONS
start_larger_than_end = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*..Separate the time got from FM into hours,minutes and seconds
CLEAR : lv_h,lv_min,lv_sec.
lv_hours = lv_days * 24 + lv_time+0(2).
lv_minuntes = lv_time+2(2).
lv_seconde = lv_time+4(2).
‎2009 Sep 14 6:20 AM
Hi,
Please try this function modulw
L_MC_TIME_DIFFERENCE
Thanks
Venkat
‎2009 Sep 14 6:25 AM
Hi
Can you make a trail to:
CCU_TIMESTAMP_DIFFERENCE
Regards,
Sreeram
‎2009 Sep 14 6:43 AM
Hi,
Check this FM's
SD_CALC_DURATION_FROM_DATETIME : Find the difference between two date/time and report the difference in hours
L_MC_TIME_DIFFERENCE : Find the time difference between two date/time
Reagrds
Kiran
‎2009 Sep 14 7:05 AM
Hi,
The Function Module - SD_CALC_DURATION_FROM_DATETIME gives you the difference between 2 Date / Times.
As per your example,
DATA: time_diff TYPE fahztd.
CALL FUNCTION 'SD_CALC_DURATION_FROM_DATETIME'
EXPORTING
i_date1 = '20090914'
i_time1 = '084000'
i_date2 = '20090914'
i_time2 = '204500'
IMPORTING
e_tdiff = time_diff
EXCEPTIONS
invalid_datetime = 1
OTHERS = 2.The output would give you the difference in hours and minutes. To get the output in your desired format, split the hours and minutes and multiply each by 60.
Hope it helps.
Regards,
Himanshu
‎2009 Sep 14 8:44 AM
Hello Dharani,
In my system the table CATSDB is not populated.
in the table catsdb there is a filed called catshours which is the difference between the two timings,but the problem is that for a time 10hours 12 mins its showing as 9.72 mins like that,my req is that ineed to get the time excattly as 10hours 12 mins
Does this not ring the "logical" BELLS in your brain )
9.72 = 9hrs + 72 mins = 10hrs 12 minsMay be you should check the unit for this (CATSDB-MEINH). I donot think you need any other calculations for this.
Hope i am clear.
BR,
Suhas