Jump to content

Problem in SUM total hours without compute the seconds


newphpcoder

Recommended Posts

Hi..

 

I notice that I got problem in my 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.

 

 

I post the sample attendance.

 

Thank you so much.

18177_.doc

Link to comment
Share on other sites

Are you sure your expected result is correct? Bare in mind you have a WHERE statement...

 

I can't actually see anything wrong with your SQL and it should be doing exactly what you ask it to. I strongly recommend reviewing your where conditions.

Link to comment
Share on other sites

I resolve my problem by changing my code for getting the rendered:

 

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.