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

  • Home
  • SEARCH
  • 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 1109871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:18:22+00:00 2026-05-17T02:18:22+00:00

The way i designed my working sheet doesn’t help me to calculate working hours

  • 0

alt text

The way i designed my working sheet doesn’t help me to calculate working hours easily.

The output in snapshot has been gathered from multiple tables.

Don’t worry regarding setDate and timeEntered formatting.

SetDate represents working day.
tsTypeTitle represents type of shift, is it lunch time, etc.
timeEntered represents the actual time.

setDate will have to be trimmed to have only Date and timeEntered should only show time – This will be handled later, don’t worry about it.

I need to grab the difference between Shift Started and Shift Ended so i can calculate the wage.

Here is my query in case you want to look at it:

SELECT TimeSheet.setDate, TimeSheetType.tsTypeTitle, TimeSheetDetail.timeEntered
FROM TimeSheet 
    INNER JOIN TimeSheetDetail 
        ON TimeSheet.timeSheetID = TimeSheetDetail.timeSheetID
    INNER JOIN TimeSheetType 
        ON TimeSheetType.timeSheetTypeID = TimeSheetDetail.timeSheetTypeID
  • 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-17T02:18:22+00:00Added an answer on May 17, 2026 at 2:18 am

    Assuming everyone has the same 4 events (shift start/end, lunch start/end) every day, you could do something like this. Obviously I’ve made assumptions for your TimeSheetType ID values. Substitute the appropriate IDs in your version.

    SELECT t.TimeSheetID, DATEDIFF(HOUR, tsd1.timeEntered, tsd4.timeEntered) - DATEDIFF(HOUR, tsd2.timeEntered, tsd3.timeEntered) as WorkingHours
        FROM TimeSheet t
            INNER JOIN TimeSheetDetail tsd1
                ON t.timeSheetID = tsd1.timeSheetID
                    and tsd1.timeSheetTypeID = 1 /* Shift Started */
            INNER JOIN TimeSheetDetail tsd2
                ON t.timeSheetID = tsd2.timeSheetID
                    and tsd2.timeSheetTypeID = 2 /* Lunch Started */
            INNER JOIN TimeSheetDetail tsd3
                ON t.timeSheetID = tsd3.timeSheetID
                    and tsd3.timeSheetTypeID = 3 /* Lunch Ended */
            INNER JOIN TimeSheetDetail tsd4
                ON t.timeSheetID = tsd4.timeSheetID
                    and tsd4.timeSheetTypeID = 4 /* Shift Ended */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a streamwriter to log errors the way it has been designed (please
Why was C# designed this way? As I understand it, an interface only describes
Is there a good way to debug errors in the Visual Studio Designer? In
Which way do you prefer to create your forms in MVC? <% Html.Form() {
Typical way of creating a CSV string (pseudocode): Create a CSV container object (like
The way you would normally include a script is with source eg: main.sh: #!/bin/bash
The way I do 80-column indication in Vim seems incorrect: set columns=80 . At
The way the iPhone uses the touchscreen to enable zooming in and out and
Efficient way to handle COM related errors in C++ . For instance: switch (HRESULT_CODE(hresult))
Whichever way I do it, it seems something goes wrong when using the conditional

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.