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

Ranges between the time

Former Member
0 Likes
1,403

Dear All,

I want to calculate the ranges between the time(12 Hrs) on the same date.

Ex:1

Date : 30.10.2008

Time : 09:00:00

Date : 30.10.2008

Time : 06:00:00

Ans: 9 Hrs (Diff Bt Time)

[[ Or.... ]]

Ex:2

No need to given as Date...just time enough for my required...

start Time : 09:00:00

end Time : 06:00:00

Ans : Same as above for EX:1

Please reply immediately....

Regards!!!

Micheal ....

Everything Is Possible...

If We are Working as Unity....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,366

Hi,

Try like this...


PARAMETERS : tim TYPE tims,
             y TYPE tims.
DATA : t TYPE string,
       t1 TYPE string,
       t2 TYPE string,
       t3 TYPE string.
 
START-OF-SELECTION.
 
  t = tim(2).
  t  = t  . " hours 
  t1 = tim+2(2).
  t1 = t1 / 60 .  " minutes to hours
  t2 = tim+4(2).
t2 = t2 / 3600. " second to hours
  t3 = t + t1 + t2. " total time in hours
" similarly try to convert y to hours..... 
 t3 = t3 - <y converted to hours>.

Regards

Debarshi

Hi,

Try like this...


PARAMETERS : tim TYPE tims,
             y TYPE tims.
DATA : t TYPE string,
       t1 TYPE string,
       t2 TYPE string,
       t3 TYPE string.
 
START-OF-SELECTION.
 
  t = tim(2).
  t  = t  . " hours 
  t1 = tim+2(2).
  t1 = t1 / 60 .  " minutes to hours
  t2 = tim+4(2).
t2 = t2 / 3600. " second to hours
  t3 = t + t1 + t2. " total time in hours
" similarly try to convert y to hours..... 
 t3 = t3 - <y converted to hours>.

Regards

Debarshi

11 REPLIES 11
Read only

Former Member
0 Likes
1,367

Hi,

Try like this...


PARAMETERS : tim TYPE tims,
             y TYPE tims.
DATA : t TYPE string,
       t1 TYPE string,
       t2 TYPE string,
       t3 TYPE string.
 
START-OF-SELECTION.
 
  t = tim(2).
  t  = t  . " hours 
  t1 = tim+2(2).
  t1 = t1 / 60 .  " minutes to hours
  t2 = tim+4(2).
t2 = t2 / 3600. " second to hours
  t3 = t + t1 + t2. " total time in hours
" similarly try to convert y to hours..... 
 t3 = t3 - <y converted to hours>.

Regards

Debarshi

Read only

0 Likes
1,366

Hi,

For Y Conversion is indicate as TOTAL HOURS or from input Hours...

Plz tell,,,

Thanks & REGARDS!!!

Micheal

Read only

0 Likes
1,366

Hi,

I said to calculate smilarly for y....


PARAMETERS : tim TYPE tims,
             y TYPE tims.
DATA : t TYPE string,
       t1 TYPE string,
       t2 TYPE string,
       t3 TYPE string,
       t4 type string,
      t5 type string,
      t6 type string,
      t7 type string,
      t8 type string.
 
START-OF-SELECTION.
 
  t = tim(2). " hours 
  t1 = tim+2(2).
  t1 = t1 / 60 .  " minutes to hours
  t2 = tim+4(2).
t2 = t2 / 3600. " second to hours
  t3 = t + t1 + t2. " total time in hours


  t4 = y(2).
  t4 = t  . " hours 
  t5 =y+2(2).
  t5 = t5 / 60 .  " minutes to hours
  t6 =y+4(2).
t6 = t6 / 3600. " second to hours
  t7 = t4 + t5 + t6. " total time in hours

 t8 = t3 - t7.-----------------> your desired result

Regards

Debarshi

Read only

bpawanchand
Active Contributor
0 Likes
1,366
DATA :
   w_d1 TYPE sy-uzeit,
   w_d2 TYPE sy-uzeit,
   w_result TYPE sy-uzeit.


w_d1 = sy-timlo.
w_d2 = 141005.
w_result = w_d1 - w_d2.

WRITE /:
    w_d1,
    w_d2,
    w_result.
Read only

0 Likes
1,366

Hi,

Its coming, But i want to calculate as 12Hrs only ,not as 24 Hrs..Plz reply..

Thanks & Regards!!!

Micheal

Read only

0 Likes
1,366

>

>9:00 in the morning

>7:00 in the evening (19:00)

>Just do 7 - 9 = -2. If the result is negative, add 12 to it. Thus the result will be 10.

Did you even try this one out?

Read only

Former Member
0 Likes
1,366

Hi,

Check FM : SD_DATETIME_DIFFERENCE

Thanks & Regards,

Navneeth K.

Read only

Former Member
0 Likes
1,366

Hi,

Try with

SD_DATETIME_DIFFERENCE

TIMECALC_DIFF

Regards,

Suresh

Read only

0 Likes
1,366

Hi,

I tried , here taking to calculate as 24 HRS ..

but , i want the 12 Hrs calculation only...

Thanks & Regards!!

Micheal

Read only

0 Likes
1,366

Hi,

From ' TIMECALC_DIFF' , this FM have different input format...

.Bcze , its having TIMESTAMP(YYYYMMDDHHMMSS)...i given this format,but it wil not taken as correctly....

Plz tell as the input format

Thanks & Regards!!

Micheal

Read only

Former Member
0 Likes
1,366

With a 12 hour notation i don;t know how the time looks in your variables.

But normally you could do a subtraction of both fields. And even if its in a 12 hour notation, the subtraction works, but you need to adjust the result:

Example:

9:00 in the morning

7:00 in the evening (19:00)

Just do 7 - 9 = -2. If the result is negative, add 12 to it. Thus the result will be 10.