By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,792 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

How to calculate break hours from in/out details in php?

P: 9
Hello All,

i want to need Idea about how to calculate break hours from in/out details


In My Database Design is:

ID EmpEntryDate EmpInTime EmpOutTime Empid
1 2014-09-22 10:28 13:21 209
2 2014-09-22 14:04 18:27 209


Break Hours : 0.47

In Below CODE i just given total sum No break Hours

Expand|Select|Wrap|Line Numbers
  1. SELECT `EmpEntryDate` , TIME_FORMAT( SEC_TO_TIME( SUM( TIMEDIFF( `EmpOutTime` , `EmpInTime` ) ) ) , "%h:%i" ) AS TOTAL_SEC
  2. FROM attemppresentdetail
  3. WHERE `Empid` = '209'
  4. AND `EmpEntryDate` = '2014-09-22'
  5. LIMIT 0 , 30
  6.  
TOTAL_SEC : 06:46

Thanks
Sep 22 '14 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,359
Join the table to itself so you can join one record to the next. That will give you the current record's out time and the next record's in time, allowing you to calculate the difference between the two.
Sep 22 '14 #2

P: 9
Hello Rabbit,

Thanks For reply ,

can you please show me any example or demo so i can understand easily.
Sep 23 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.