SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Problem in Time

  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem in Time

    Hi..


    I got an issue in getting the total time.

    I have this code to get the sum of total time:

    Code:
    $result = mysql_query("INSERT INTO payroll.casual_hours(EMP_NO, Hours) SELECT EMP_NO, sec_to_time(SUM(time_to_sec(Rendered))) FROM payroll.casual_att WHERE DATE_FORMAT(LOGOUT, '%W') IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') GROUP BY EMP_NO") or die(mysql_error());
    Rendered:
    09:00:00
    09:00:00
    09:00:00
    08:00:00
    08:00:00
    07:48:00

    and the result of this is 50:48

    but I need result is 50:80

    the minutes is divided to 60

    Is there any way to get the 50:80 result.


    Thank you so much..

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    sure, just do the calculation yourself, i.e. instead of using SEC_TO_TIME, divide the results of SUM(TIME_TO_SEC(...)) by 60 yourself right in the query

    alternatively, and preferably, pass the results of SUM(TIME_TO_SEC...)) to php and do the calculation there
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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