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

time calculation

Former Member
0 Likes
398

Could someone explain me the following from the code below:-

q1]] How do we get "72000 and 7200 " ?

q2]] How do we get "-64800"?

q3]] what is the possible answer ? Is not it that from say 2 ' o clock morning to 8 ' clock evening i,e., we get 18 hours----


then why is this logic required??

code:-

Example of a time calculation:

DATA: DIFF TYPE I,

SECONDS TYPE I,

HOURS TYPE I.

DATA: T1 TYPE T VALUE '200000',

T2 TYPE T VALUE '020000'.

DIFF = T2 - T1.

SECONDS = DIFF MOD 86400.

HOURS = SECONDS / 3600.

The number of hours between 02:00:00 and 20:00:00 is calculated.

1. First, the difference between the time fields is calculated. This is -64800, since T1

and T2 are converted internally into 72000 and 7200 respectively.

2. Second, with the operation MOD, this negative difference is converted to the total

number of seconds. A positive difference would be unaffected by this calculation.

3. Third, the number of hours is calculated by dividing the number of seconds by 3600.

The last three lines can be replaced by the following line

HOURS = ( ( T2 - T1 ) MOD 86400 ) / 3600

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
351

hi,

it seems mathematical calculations needed for ur query.

1) 20 hrs is converted internally to seconds that is 20 * 60 * 60 = 72000 sec.

2 hrs is converted internally to seconds that is 2 * 60 * 60 =7200 sec.

2) As per ur program u have mentioned as 2 hrs - 20 hrs.

I put it in a correct form, 7200 - 72000 which gives u -64800 sec.

Regards...

Arun.

Reward points if helpful.

1 REPLY 1
Read only

Former Member
0 Likes
352

hi,

it seems mathematical calculations needed for ur query.

1) 20 hrs is converted internally to seconds that is 20 * 60 * 60 = 72000 sec.

2 hrs is converted internally to seconds that is 2 * 60 * 60 =7200 sec.

2) As per ur program u have mentioned as 2 hrs - 20 hrs.

I put it in a correct form, 7200 - 72000 which gives u -64800 sec.

Regards...

Arun.

Reward points if helpful.