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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts

    Problem in SUM total hours without compute the seconds

    Hi..

    I notice that I got problem in my code:

    Code:
    SELECT sec_to_time(SUM(time_to_sec(Rendered))) FROM reg_att WHERE EMP_NO = '09300139';

    in this query the output is : 103:52:27 // total hours.

    but it's wrong it should only be 103:51 //if did not count the seconds.

    Now my question is what would be the syntax to correct the result.


    this is the sample data:

    08:00:00
    08:00:00
    08:00:00
    08:00:00
    08:00:00
    08:00:00
    08:00:00
    08:00:00
    08:00:00
    08:00:00
    08:00:00
    07:56:42
    07:55:45
    Thank you so much.

  • #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

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,447
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    Talk about a way to be sure you don't get answers...

    No wonder it seems that NewPHPCoder often ignores my answers. I guess I don't need to bother answering him any more.
    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.

  • #4
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts
    I resolve my problem by changing my code for getting the rendered:

    Code:
    when time_to_sec(time(LOGIN)) BETWEEN time_to_sec('10:00:00') AND time_to_sec('10:35:00') AND time_to_sec(time(LOGOUT)) BETWEEN time_to_sec('13:35:00') AND time_to_sec('14:35:00')
    AND DATE_FORMAT(LOGIN, '%W') IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
    then sec_to_time(CEIL((time_to_sec(concat(substr(LOGOUT, 1,10), ' ' , '04:00:00')) +
    (time_to_sec(LOGOUT) - time_to_sec(concat(substr(LOGOUT, 1,10), ' ' , '14:35:00')))) / 60) * 60)
    Thank you

  • #5
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Talk about a way to be sure you don't get answers...

    No wonder it seems that NewPHPCoder often ignores my answers. I guess I don't need to bother answering him any more.
    I'm sorry if I'm late in answering your post, cause I tried my best also to correct my codes. But thank you so much for your effort to help me..

    I hope you don't get mad to me

  • #6
    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
    The idea is for you to pick a forum, any ONE of them, and stick to posting in it. You post many questions in a day (and that's okay to have questions), you are just wasting time when you post in multiple forums so one person is working on a solution for you yet you've already got an answer in a different forum.


  •  

    Posting Permissions

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