Calculating hours worked from a time stamp

45 pts.
Tags:
AS/400
RPGILE
Hi Everyone

I work for a trucking company and all of the trucks have onboard computers with GPS tracking, recently the company decided to have the local drivers clock in and out on the OBC that way they also have the location of the unit when the driver clocks in or out. My question is they want a report of each driver and the hours worked for each day. I tried using the SUBDUR function for the two time stamps but the result for the hours worked is not exactly correct it can be off by a few tenths of a minute. I tried using the hour  function but will not show over whole hours so I used the minute function and then divide to total minutes by 60 but that is off by tenths sometimes the time is high and others are low. Below are the calculations

D @clkit          S               T   

 D @clkot          S               T   

 D @mnswk          S              5  0 

 D @hrswk          S              5S 3 

C     @clkot        subdur    @clkit        @mnswk:*MN   

C                   If        @mnswk> 0                  

C                   Eval      @hrswk = @mnswk / 60       

C                   Endif                                

Is there a better way getting the hours worked

Thanks, Billy

 



Software/Hardware used:
AS/400 RPGILE
ASKED: November 20, 2009  5:06 PM
UPDATED: November 25, 2009  7:58 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

off in the seconds…but you computed mintuesD @clkit S T

D @clkot S T

D @secswk S 7 0

D @hrswk S 7S 4

C @clkot subdur @clkit @scswk:*S

C If @scswk> 0

C Eval @hrswk = @scsswk / 3660

Phil

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Braz
    Thanks Phil
    45 pointsBadges:
    report
  • RonKoontz
    Braz, send me an email .I have a few other things for ya. rkoontz@ceioh.com Thanks
    1,780 pointsBadges:
    report
  • Teandy
    Try something like this:
    
    d  total_seconds  s              9  0 inz(0)
    d  decmial_hours  s              5  2 inz(0) 
    D  time1          S               t   inz(T'12.00.00')   
    D  time2          S               t   inz(T'13.38.00')   
    
    /Free                                                         
                                                                  
       total_seconds = %diff(time2 : time1 : *s);                  
      decmial_hours = (total_seconds / 60) / 60;                  
                                                                  
     *INLR = *ON;                                                 
     RETURN;                                                      
                                                                  
    /End-Free    
    
    
    The variable decmial_hours should now have a value of 1.63. Is this what you are looking for?
    5,860 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following