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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemal8888
    New Member
    • Mar 2013
    • 9

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

    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

    Code:
    SELECT `EmpEntryDate` , TIME_FORMAT( SEC_TO_TIME( SUM( TIMEDIFF( `EmpOutTime` , `EmpInTime` ) ) ) , "%h:%i" ) AS TOTAL_SEC
    FROM attemppresentdetail
    WHERE `Empid` = '209'
    AND `EmpEntryDate` = '2014-09-22'
    LIMIT 0 , 30
    TOTAL_SEC : 06:46

    Thanks
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    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.

    Comment

    • hemal8888
      New Member
      • Mar 2013
      • 9

      #3
      Hello Rabbit,

      Thanks For reply ,

      can you please show me any example or demo so i can understand easily.

      Comment

      Working...