Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts

    Question Sum of time differences

    Hi CF Board

    i have for eg
    Code:
    sopno	 no field puser 	 progstart 	 progend
    101299 	11.65 	Graeme 	 	13-03-14 15:49 	13-03-14 16:01 		
    101289 	179.05 	Graeme 		13-03-14 19:21 	13-03-14 22:20 		
    101289 	445.3 	Graeme 		17-03-14 08:20 	17-03-14 15:46
    where no field is a PHP calculation of the start and finish times,

    i want to display this as 1 line or maybe a summary line beneath it

    so i want to time calc in mysql instead of php, or should i store the calc in the table also?
    then i want to group by sopno but add the calculations together

    current code:
    Code:
    select 
    						  A.id As id,
    						  A.sopno As sopno,
    						  A.progstart As progstart,
    						  A.progend As progend,
    						  A.puser As apuser,
    						  A.cstart As cstart,
    						  A.cend As cend,
    						  A.cuser As acuser,
    						  A.status As status,
    						  
    						  B.FirstName As puser,
    						  
    						  C.FirstName As cuser
    						from
    						  ( ( aventa_program A 
    						  left join webbook.users B on B.UserID = A.puser  )
    						  left join webbook.users C on C.UserID = A.cuser  ) 
    						  ORDER BY `status`, `sopno` DESC limit 200"
    current time calc

    PHP Code:
    // shortened code
                
    if ($TData['progend'] != NULL){$to_time strtotime($TData['progend']);}else{$to_time strtotime("now");}
                if (
    $TData['progstart'] != NULL){$from_time strtotime($TData['progstart']);}else{$from_time strtotime("now");}

                <
    td>'.$TData['sopno'].'</td>
                <
    td>'.(round(abs($to_time - $from_time) / 60,2)).'</td>
                <
    td>'.$PUSER.'</td>

                
    $psdate date_create($TData['progstart']);
                
    $pedate date_create($TData['progend']);

                
                if (
    $TData['progstart'] != NULL){$psdateshow date_format($psdate'd-m-y H:i');}else{$psdateshow ='';}
                if (
    $TData['progend'] != NULL){$pedateshow date_format($pedate'd-m-y H:i');}else{$pedateshow ='';}

                    
                
    $Content .= '
                <td>'
    .$psdateshow.'</td>
                <td>'
    .$pedateshow.</td
    Last edited by Arcticwarrio; 03-18-2014 at 03:05 PM.
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month


 

Posting Permissions

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