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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Aug 2011
    Posts
    101
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Internet Explorer adding time in a column.

    I have a time_utilization column in my table. Now, I want to add the time depending on the two selected dates.

    I tried the below query but not working.

    Code:
    $qry = "select SEC_TO_TIME(SUM(time_utilization)) from users where date between '2011-11-20' AND 2011-11-22";
    $result=mysql_query($qry);

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    your example is not clear.

  • #3
    Regular Coder
    Join Date
    Aug 2011
    Posts
    101
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question

    Hi, I have a column call "time_utilization". This field holds the TIME in "hh:mm:ss" format. There are more than 15 rows in this column. Now, I want to add the time in this column to get the total time.

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    There is a maximum value that TIME can hold, I believe it is around 825 hours, so if your total is above that amount it will round off to that value. See the manual for exact value.

  • #5
    Regular Coder
    Join Date
    Aug 2011
    Posts
    101
    Thanks
    7
    Thanked 0 Times in 0 Posts
    That's fine with me. How to do that. Can you please help me? Thank you.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,947
    Thanks
    79
    Thanked 4,424 Times in 4,389 Posts
    The big question: What is the *DATATYPE* of your time_utilization field??? If it is not DATETIME, then you will have to convert it.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Regular Coder
    Join Date
    Aug 2011
    Posts
    101
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Question

    I converted the datatype as you specified. Now could you provide the exact syntax to add time. Also I tried the below code to test the time count works or not:


    PHP Code:


     $qry 
    "select SEC_TO_TIME(SUM(TIME_TO_SEC(time_utilization))) from tracker"
    $result=mysql_query($qry) or die (mysql_error());
     
    echo 
    $result


  •  

    Posting Permissions

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