Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9165015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:49:03+00:00 2026-06-17T14:49:03+00:00

I am working on an online time card system and have ran into a

  • 0

I am working on an online time card system and have ran into a road block. What I need to do is calculate in each row the timeIn and timeOut for a date the employee might clock in and out several times a day. I have a working query to find the total for the entire day but not for each individual row. I have included the structure of the database table with some examples of what I would like to see.

+----+------------+----------+---------+------------------------------+-------------+------------+-----------+----------+
| id | employeeID | date     | timeIn  | jobDescription               | equipType   | unitNumber | unitHours | timeOut  |
+----+------------+----------+---------+------------------------------+-------------+------------+-----------+----------+
|  8 |          1 | 01/15/13 | 7:00 AM | Loaded sand in Jefferson     | Excavator   | 345        |      NULL | 9:30 PM  |
|  9 |          1 | 01/15/13 | 10:00 AM | Loaded sand in Jefferson     | Excavator   | 345        |      NULL | 12:00 PM |
| 10 |          1 | 01/16/13 | 7:00 AM | Loaded sand in Jefferson     | Excavator   | 345        |      NULL | 5:30 PM  |
| 11 |          1 | 01/17/13 | 7:00 AM | Loaded sand in Jefferson     | Excavator   | 345        |      NULL | 5:30 PM  |
| 12 |          1 | 01/18/13 | 8:00 AM | Backfill in Whispering Creek | Skid Loader | 297        |      NULL | 5:30 PM  |
| 13 |          1 | 01/19/13 | 8:00 AM | Backfill in Whispering Creek | Skid Loader | 297        |      NULL | 3:30 PM  |
|  1 |          1 | 01/20/13 | 6:00    |                              | Excavator   | 01E        |      7238 | 17:00    |
|  2 |          1 | 01/21/13 | 6:00    | Worked in Jefferson          | Excavator   | 01E        |      7238 | 17:00    |
|  3 |          1 | 01/22/13 | 6:00    | Worked in Jefferson          | Excavator   | 02E        |      7238 | 17:30    |
|  4 |          1 | 01/23/13 | 6:00    | Worked in Whispering Creek   | Skid Loader | 32SL       |      2338 | 18:30    |
|  5 |          1 | 01/24/13 | 8:00    | Worked in Hubbard            | Scraper     | 54C        |      9638 | 11:30    |
|  6 |          1 | 01/25/13 | 8:00    | Worked in Jefferson          | Dozer       | 4D         |       941 | 19:30    |
|  7 |          1 | 01/26/13 | 8:00    | Pushed Snow                  | Loader      | 950H       |       342 | 20:30    |
+----+------------+----------+---------+------------------------------+-------------+------------+-----------+----------+

Ok so what I would like to see is that for example the date 01/15/13 appears twice with different timeIn and timeOut values I would like to get a value back saying that in row with the id 8 there was 2:30 hours, then get another value back saying that in the row where id is 9 there was 2:00 hours. I would like to accomplish this with one query if possible.

This is my query to get the time for the entire day:

SELECT `employeeID`, SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(`timeOut`, `timeIn`))))   AS `totalTime` FROM `timeRecords` WHERE   `date` = "01/15/13"  AND `employeeID` = 1 GROUP BY `employeeID`;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:49:04+00:00Added an answer on June 17, 2026 at 2:49 pm

    If I understand you correctly you need this?

    SELECT `employeeID`, TIMEDIFF(`timeOut`, `timeIn`)  AS `totalTime` FROM `timeRecords`;
    

    You can use PDO query to query your database which returns result set as array of associative array. For better performance you can use PDO prepare/execute.

    <?php
    function getTimeByRow($connection) {
        $sql = "SELECT `employeeID`, TIMEDIFF(`timeOut`, `timeIn`)  AS `totalTime` FROM `timeRecords`";
        foreach ($connection->query($sql) as $row) {
            print $row['employeeID'] . "\t";
            print $row['totalTime'] . "\n";
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an online time card system to replace the paper time
I'm working on an online forex trading system and a while back we have
I am working on online pdf library project. In this I have a feature
I am working on a online shopping website, it will have product images also.
I am working on an online video repository system for a client, written mostly
I am working on project -online file management where we have to tore file
I'm working on an online store. I have it setup on my testing server.
I'm working on an online booking system and currently use a table bookings (id,
I'm working on an online PHP application that has a need for delayed PHP
I'm working on a small online game where there is a need to store

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.