CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
adding time in minutes and averaging up per hour



Jan 30, 2010, 2:45 PM

Post #1 of 1 (720 views)
adding time in minutes and averaging up per hour Can't Post

I have this report and it works when i add hour and minute (Ex. 1hr2min) but when i try to use minutes (Ex. 62min.) it doesnt add up right and makes my average wrong.

Here is what i want my output to look like
start date |wg |users |function |time to complete work |total work |average time to complete work
10/12/09 8:00 |1 |user1 | 1 | 180min |2 |90

I hope this makes sense

any help or ideas would be awesome.

heres my code:

#!/usr/bin/env perl 

while( <DATA>) {

my ($user, $work, $workgroup, $function, $starttime, $comptime) = split(/\;/,$_);
my ($sday, $smonth, $syear, $shour, $sminute) = split(/\/|\s|:/,$starttime);
my ($cday, $cmonth, $cyear, $chour, $cminute) = split(/\/|\s|:/,$comptime);


$output{$user}{$function}{'Time'} = (((($chour+$cminute)))-((($shour+$sminute))));


print OUT "DATE |WG |Function |TIME |COUNT |AVR\n";
foreach my $user (sort keys %output) {
foreach my $function (sort keys %{$output{$user}}) {
($startdate,$time) = split(" ", $starttime);

$user2 .= $pad_char x ( $pad_len_user - length( $user2 ) );

print OUT "$startdate | $wg | $user2 | $func | $output{$user}{$function}{'Time'} |$output{$user}{$function}{'Count'} |.(int($output{$user}{$function}{'Time'}/3600))\n";

user1;ef1;1;1;10/12/09 8:00;10/12/09 10:00
user1;ef2;1;1;10/12/09 11:00;10/12/09 12:00
user1;ef3;1;2;10/12/09 13:00:00;10/12/09 15:00
user2;efs1;1;1;10/12/09 8:00;10/12/09 10:00
user2;efs2;1;2;10/12/09 10:00;10/12/09 15:00
user2;efs3;1;2;10/12/09 16:00;10/12/09 18:00


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives