Announcement

Collapse
No announcement yet.

Sum a Range of Hours, Minutes, Seconds

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gregery D Engle
    replied
    Bern and Tom,

    I think the easiest way to do it would be the way Tom discribes.

    I'll post some working code when I'm finished with it.

    ------------------
    -Greg

    Leave a comment:


  • Bern Ertl
    replied
    What storage structure are you using for the hh:mm:ss?

    It seems to me that you should be able to do the math directly on the
    seconds, minutes and hours (separately) without the need to convert all
    to seconds. Just be sure to carry any overflow of seconds or minutes
    forward. Of course, this assumes that you are storing the hours,
    minutes and seconds in unique vars (array elements).



    ------------------
    Bernard Ertl

    Leave a comment:


  • Tom Hanlin
    replied
    Convert to seconds and store 'em that way. You'll only have a single value to deal
    with and you can readily do calculations. Convert 'em back to displayable values
    when you need to display 'em.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Michael Mattias
    replied
    The only suggestion I have is to do it the old-fashioned way:

    Extract all the hoursfrom the hh:mm:ss, multiply by 24 * 60
    Extract all the minutes, multiply by 60
    Extract and add the seconds.

    You now have a total number of seconds.

    Divide as needed for desired target time units.

    Seems faster than digging thru MSDN and the API reference.

    MCM

    Leave a comment:


  • Gregery D Engle
    started a topic Sum a Range of Hours, Minutes, Seconds

    Sum a Range of Hours, Minutes, Seconds

    Assume:

    1:03:00
    -1:03:00
    -0:00:00
    8:24:00
    9:25:00
    -2:54:00

    I want to have an Array and return the Total for Hours/Minutes/Second.

    Any suggestions?



    ------------------
    -Greg
Working...
X