2006 Jun 30 8:40 AM
Hello,
I have to add times (hh:mm). how can i do this?
thanks.
2006 Jun 30 8:48 AM
Hi lois,
1. If we add times, DATE also comes in to picture.
2. Other wise
3. U can simply use time1 + time2
4. Just copy paste
5.
report abc.
data : tm1 type sy-uzeit.
data : tm2 type sy-uzeit.
data : tm3 type sy-uzeit.
tm1 = sy-uzeit.
tm2 = '034500'.
tm3 = tm1 + tm2.
write 😕 tm1.
write 😕 tm2.
write 😕 '----
'.
write 😕 tm3.
regards,
amit m.
Hi again,
1. if time is stored in database,
as character data, with COMMA,
2. then we have to do some extra thing,
thats all.
3. just copy paste
REPORT ABC.
DATA : MYTIME(8) TYPE C.
DATA : T1 TYPE SY-UZEIT.
*----
MYTIME = '06,45,00'.
WRITE 😕 'BEFORE ' , MYTIME.
REPLACE ALL OCCURRENCES OF ',' IN MYTIME WITH ''.
T1 = MYTIME.
WRITE 😕 'AFTER ' , T1.
regards,
amit m.
2006 Jun 30 8:42 AM
2006 Jun 30 8:48 AM
Hi lois,
1. If we add times, DATE also comes in to picture.
2. Other wise
3. U can simply use time1 + time2
4. Just copy paste
5.
report abc.
data : tm1 type sy-uzeit.
data : tm2 type sy-uzeit.
data : tm3 type sy-uzeit.
tm1 = sy-uzeit.
tm2 = '034500'.
tm3 = tm1 + tm2.
write 😕 tm1.
write 😕 tm2.
write 😕 '----
'.
write 😕 tm3.
regards,
amit m.
2006 Jun 30 8:50 AM
Hi,
Try
time1 + time2
Regards,
Tanveer.
<b>Please mark helpful answers</b>
2006 Jun 30 9:01 AM
Thanks very much for your interet and i want to ask also how can i show the rate of two time? how can i calculate this? for ex: 03:45:00/15:00:00 = 25%
thanks again.
2006 Jun 30 9:04 AM
Hi again,
1. just copy paste
2. it will give 25.
3.
report abc.
data : tm1 type sy-uzeit.
data : tm2 type sy-uzeit.
data : tm3 type sy-uzeit.
data : rt type i.
tm1 = '034500'.
tm2 = '150000'.
tm3 = tm2 / tm1.
write 😕 tm1.
write 😕 tm2.
write 😕 '----
'.
write 😕 tm3.
rt = 100 / tm3+4(2).
write 😕 '----
'.
write 😕 rt.
2006 Jun 30 9:12 AM
But when i use "tm2 = sy-uzeit", it does not give me right reponse:(
2006 Jun 30 9:28 AM
Hi again,
1. do like this.
2. this will convert both times,
into their respective SECONDS,
and divide,
and give accurate results, in 2 decimals.
3.
report abc.
data : tm1 type sy-uzeit.
data : tm2 type sy-uzeit.
data : rt type p decimals 2.
data : sec1 type i.
data : sec2 type i.
tm1 = '150000'. "--- bigger time
tm2 = '034500'.
tm2 = sy-uzeit.
sec1 = ( tm1(2) * 3600 ) + ( tm1+2(2) * 60 ) + ( tm1+4(2) ) .
sec2 = ( tm2(2) * 3600 ) + ( tm2+2(2) * 60 ) + ( tm2+4(2) ) .
rt = sec1 / sec2.
write 😕 tm1.
write 😕 tm2.
write 😕 '----
'.
write 😕 rt.
regards,
amit m.
2006 Jun 30 9:51 AM
Oh my god, i have an another problem:(, they registered time (not like hh:mm:ss) like this hh,mm,ss in database. how can i do all of this operations when time used hh,mm,ss.
thanks.
2006 Jun 30 9:58 AM
Hi again,
1. if time is stored in database,
as character data, with COMMA,
2. then we have to do some extra thing,
thats all.
3. just copy paste
REPORT ABC.
DATA : MYTIME(8) TYPE C.
DATA : T1 TYPE SY-UZEIT.
*----
MYTIME = '06,45,00'.
WRITE 😕 'BEFORE ' , MYTIME.
REPLACE ALL OCCURRENCES OF ',' IN MYTIME WITH ''.
T1 = MYTIME.
WRITE 😕 'AFTER ' , T1.
regards,
amit m.
2006 Jun 30 10:14 AM
2006 Jun 30 12:12 PM
Finally, i excuse and i want to say something again. they registered time hh,mm. When i replace with :,it change like hh:mm:. And i can do operations when it ends with :.
2006 Jun 30 12:18 PM
Hi again,
1. When i replace with :,it change like hh:mm:.
We are NOT replacing COMMA with :
2. The time field,
does not have :.
3. it consists of data in this format,
HHMMSS
4. WHEN we display it using WRITE statement,
it AUTOMATICALLY SHOWS IN this format
HH:MM:SS
regards,
amit m.
2006 Jun 30 12:29 PM
i understood what you have done. but i must change hh,mm (my datas are in this form) to hh:mm for doing operations.
2006 Jun 30 12:30 PM
Hi again,
1. if u want to replace , with :
2. then
REPLACE ALL OCCURRENCES OF ',' IN MYTIME <b>WITH ':'.</b>
regards,
amit m.
2006 Jun 30 9:20 AM
Use WRITE ... TO ...Option
REPORT ZADDTIME .
DATA: V_TIM1 TYPE T,
V_TIM2 TYPE T,
V_TIM3 TYPE SY-UZEIT.
<b>WRITE SY-UZEIT TO V_TIM1.</b>
<b>WRITE '034500' TO V_TIM2.</b>
V_TIM3 = V_TIM1 + V_TIM2.
WRITE: V_TIM3.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |