+ Reply to Thread
Results 1 to 6 of 6

Thread: Tech Tip: Elapsed Time Function

  1. #1
    Guest.Visitor Guest

    Default Tech Tip: Elapsed Time Function

    I am little confused. Why would I want to write an entire procedure to do what is already available (and BETTER!) in RPG? You are using Date and Time fields. Why not use a Timestamp field? This would allow to calculate elpased times less than a second (of course how accurate would these times really be??). You are using the %Diff() BIF. Why not use the %Diff() against the 2 Timestamp fields directly? You are using you own code to return the elapsed time in different units (Hours, Days, etc.). Why not use the optional 3rd parm on %Diff()? As you can see, ALL of the functionallity you have written into your procedure are directly available by using 2 Timestamp fields (with the TIME op-code) and the %Diff() BIF. So, what's the point? Brian

  2. #2
    Guest.Visitor Guest

    Default Tech Tip: Elapsed Time Function

    If you've already got the "From" and "To", why not just use the SUBDUR opcode, then you'll get the difference with one line of code. Matt

  3. #3
    Guest.Visitor Guest

    Default Tech Tip: Elapsed Time Function

    What you're saying is true; however, that could be said of any user-defined function. The point of this is to take what would otherwise be a multi-step process and convert it into a format that can be used on a single EVAL statement. While this can be accomplished with SUBDUR, the function will do both date and time in one step. The tech tip itself was written in response to a question that I've heard other iSeries programmers ask. Mike

  4. #4
    Guest.Visitor Guest

    Default Tech Tip: Elapsed Time Function

    Another way to easily compute duration given two dates and times is using builtin function %DIFF() as follows: dur=%diff(d1+t1:d2+t2:*minutes); That is, you can "add" together a date value and a time value to get a timestamp value, and you can then compute the difference of the two timestamps. Cheers! Hans

  5. #5
    Guest.Visitor Guest

    Default Tech Tip: Elapsed Time Function

    Hello, why using a couple of statements, when SQL needs only one. Here an example how to calulate date/time difference with embedded SQL: Birgitta
    Code

  6. #6

    Default Tech Tip: Elapsed Time Function

    This is a discussion about Tech Tip: Elapsed Time Function.

    Click here for the article.


+ Reply to Thread

Similar Threads

  1. Tech Tip: SQL GetMiles Function
    By kbuckley@csepromo.com in forum SQL
    Replies: 16
    Last Post: 02-26-2004, 07:17 AM
  2. Time Slice function
    By Guest.Visitor in forum Programming
    Replies: 2
    Last Post: 09-04-2001, 08:58 AM
  3. QPADEVnnn - Tech Tip
    By Guest.Visitor in forum Programming
    Replies: 1
    Last Post: 04-19-2001, 01:29 PM
  4. Orlando Tech Conference
    By J.Wells in forum Analysis
    Replies: 1
    Last Post: 11-02-2000, 05:43 PM
  5. AS/400 Tech conference in LV
    By Guest.Visitor in forum Analysis
    Replies: 28
    Last Post: 10-29-1999, 05:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts