Time Elapsed

150 pts.
Tags:
AS/400
I am getting the wrong result in the %DIFF function. See following code:

D total_hours s 9 2 inz(0)

D time1 S t inz(T'12.00.00')

D time2 S t inz(T'13.38.00')

 /Free total_hours = %diff(time2 : time1 : *h);

 *inLR = *on;

 /End-Free

C RETURN

I was expecting 1.38. and I am getting 1.00.

Any suggestions?

 



Software/Hardware used:
RPGLE AS/400

Answer Wiki

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

Total hours is defined as numeric and should be defined as a time field like your ither fields.

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
  • philpl1jb
    %diff(time2 : time1 : *h); *h -- number of hours -- 1 hour %diff(time2 : time1 : *minutes); number of minutes returns not 1.38 but 60 + 38 = 98 Hope this helps Phil
    50,860 pointsBadges:
    report
  • BigKat
    Actually, %DIFF returns an integer of the number of FULL units between the 2 values so you will only see 1.00 in your total hour field what you want is to retrieve the minutes divided by 60;
    d total_hours     s              9p 2                 
    d time1           s               t   inz(T'12.00.00')
    d time2           s               t   inz(T'13.38.00')
                                                          
     /free                                                
         total_hours = %diff(time2 : time1 : *mn)/60;     
         dump(a);                                         
         *inlr = *on;                                     
     /end-free                                            
    
    8,350 pointsBadges:
    report
  • a1maida
    Thanks for your help.
    150 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