All i need to do is add hours and minutes to get a total time. Here is what i have so far.
while (@row = $sth->fetchrow()){ $total_minutes = $row[5]; $total_hours = $row[4] * 60; #multiply hours by 60 to get minute +s $all_minutes = $total_hours + $total_minutes; $total_time = $total_time + $all_minutes; $total_time_hours += int($total_time / 60); $total_time_minutes = $total_time % 60; $all_time = "$total_time_hours:$total_time_minutes"; ## Make our HTML look better if no data. $row[0] = "&nbsp;" if($row[0] eq ""); $row[1] = "&nbsp;" if($row[1] eq ""); $row[2] = "&nbsp;" if($row[2] eq ""); $row[3] = "&nbsp;" if($row[3] eq ""); $row[4] = "&nbsp;" if($row[4] eq ""); $row[5] = "&nbsp;" if($row[5] eq ""); $row[6] = "&nbsp;" if($row[6] eq ""); @date_array01 = split(/ /,$row[2]); $print_date = $date_array01[0]; $in_time_sec = $date_array01[1]; @in_time_array = split(/:/,$in_time_sec); $in_time = join(":",$in_time_array[0],$in_time_array[1]); @date_array02 = split(/ /,$row[3]); $out_time_sec = $date_array02[1]; @out_time_array = split(/:/,$out_time_sec); $out_time = join(":",$out_time_array[0],$out_time_array[1]); print <<HTML; <TR BGCOLOR="#FFFFFF"> <TD><FONT SIZE=2 FACE=ARIAL>$print_date</FONT></TD> <TD><FONT SIZE=2 FACE=ARIAL>$in_time</FONT></TD> <TD><FONT SIZE=2 FACE=ARIAL>$out_time</FONT></TD> <TD BGCOLOR="#FFFFCC"><FONT SIZE=2 FACE=ARIAL>$row[4]:$row[5]</FON +T></TD> <TD><FONT SIZE=2 FACE=ARIAL>$row[6]</FONT></TD> HTML } # End of while. print<<HTML; </TR><tr> <td BGCOLOR="#eecb27" colspan=2></TD> <td><B>Total Time:</B></TD><td bgcolor=#FFFF99><B>$all_time</B></TD>

Basically this while statement prints a table to display all times in a database. At the bottom a total of the number of minutes and hours are displayed at the bottom. In this particular code i'm testing adding two times.
4:23 and
5:13
funny i get 13:36 as the $all_time

In reply to Time Totaling re-explained by nlafferty

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.