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 7048303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:52:33+00:00 2026-05-28T02:52:33+00:00

So, we have a table, called timePunches : CREATE TABLE `timePunches` ( `punchID` INT(11)

  • 0

So, we have a table, called timePunches:

CREATE TABLE `timePunches` (
    `punchID` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'The unique ID of the punch',
    `employeeID` VARCHAR(50) NOT NULL COMMENT 'Who did the punch',
    `punchDATETIME` DATETIME NOT NULL COMMENT 'The time of the punch',
    `punchDTC_LINK` DATETIME NULL DEFAULT NULL COMMENT 'The previous start time for the OUT punch',
    `punchDATECRC` INT(100) NOT NULL COMMENT 'The punch CRC, to prevent hacking',
    `punchDIRECTION` TINYTEXT NOT NULL COMMENT 'What the punch did',
    `punchTOTAL` INT(11) NULL DEFAULT NULL,
    `fullName` TEXT NULL,
    PRIMARY KEY (`punchID`)
)
COLLATE='latin1_swedish_ci'
ENGINE=MyISAM
ROW_FORMAT=DYNAMIC
AUTO_INCREMENT=15825

This table is used for tracking punch times from our employees. Meaning, we track when they punch in and punch out. This table is an audit compliance table, meaning that we do not SELECT/UPDATE records, instead, we SELECT/INSERT them only.

So, this is what happens when a user punches the clock:

  • PUNCH IN: Application sends employeeID (string), punchDATETIME (DateTime), punchDATECRC (int) and punchDTC_LINK (DateTime [null]) to the database via a stored procedure. This stored procedure adds the necessary information to the database, to include triggering an internal function to pull the full name of the user into the same table.

  • PUNCH OUT: Application sends employeeID (string), punchDATETIME (DateTime), punchDATECRC (int) and punchDTC_LINK (DateTime) to the database. The stored procedure adds the necessary information, including the trigger to do the math between both DateTime elements, and fill out the legal name.

As we can see from the above, when the user punches IN, the query looks kind of like this:

INSERT INTO timePunches (punchID, employeeID, punchDATETIME, punchDTC_LINK, punchDATECRC, punchDIRECTION, punchTOTAL) VALUES (15797, ‘prumple’, ‘2012-01-11 17:35:10’, NULL, -2011509138, ‘IN’, NULL);

And, when the user punches out, it sends something like this:

INSERT INTO timePunches (punchID, employeeID, punchDATETIME, punchDTC_LINK, punchDATECRC, punchDIRECTION, punchTOTAL) VALUES (15797, ‘prumple’, ‘2012-01-11 19:39:52’, ‘2012-01-11 17:35:10’, -2011509138, ‘OUT’, NULL);

So, as we can see, there are 2 elements in the DataTable for this user. One IN and one OUT.

What I need to do, is find out if the user has forgotten to punch OUT. So, let’s say that a user punches IN, works all the day long, closes their punch clock w/o clocking out, and then the next day punches IN again. HE then works his full shift, and remembers to punch out this time.

Now, for that situation, we have 2 IN punches, and only 1 OUT punch. I need a way to detect this.

  • 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-05-28T02:52:33+00:00Added an answer on May 28, 2026 at 2:52 am

    If I understand correctly, an ‘IN’ record’s corresponding ‘OUT’ record will match on employeeID (the punch is for the same employee) and the ‘IN’ DATETIME will match the ‘OUT’ DTC_LINK.

    -- Fetch all 'IN' records without a corresponding 'OUT'
        SELECT tp_in.*
         FROM timePunches tp_in
    LEFT JOIN timePunches tp_out
              ON tp_in.employeeID = tp_out.employeeID
                 AND
                 tp_in.punchDATETIME = tp_out.punchDTC_LINK
        WHERE tp_in.punchDIRECTION = 'IN'
              AND
              tp_out.punchDTC_LINK IS NULL;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a table called table1 ... (c1 int indentity,c2 datetime not null,c3 varchar(50)
I have table name called Person with following column names P_Id(int), LastName(varchar), FirstName (varchar).
I have a table called BlogPost which has a 1-to-many relationship with the Comment
Assuming I have table called events with the columns INT id DATETIME start_time DATETIME
I have a table called PurchaseOrderDetail. TABLE PurchaseOrderDetail PurchaseOrderDetail int, Comments nvarchar(500) In the
I have one table called EmployeeSalary with two columns EmpID(int) and Salary(decimal(15,2)) While selecting
I have table called stats . In am inserting yes or no in the
I have a table called OffDays, where weekends and holiday dates are kept. I
I have a Table called Product and I have the Table StorageHistory . Now,
I have a table called ApprovalTasks... Approvals has a status column I also have

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.