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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:59:53+00:00 2026-06-10T21:59:53+00:00

I have a timesheet table and a department table with date ranges and want

  • 0

I have a timesheet table and a department table with date ranges and want to attach the correct department to each timesheet entry.

Timesheet                        Department
----------------------           --------------------------------------
Name  |Date     |Hours           Name   |From     |To        |Dept
----------------------           --------------------------------------
Joe   |6/1/2012 | 4              Joe    |5/1/2012 |7/31/2012 |West
Joe   |7/8/2012 | 2              Joe    |8/1/2012 |1/1/2099  |East
Joe   |8/4/2012 | 8

When querying the timesheet data I want the correct department for the day of the timesheet attached. The query should output this:

Joe   |6/1/2012 | 4 |West
Joe   |7/8/2012 | 2 |West
Joe   |8/4/2012 | 8 |East

I have a hard time getting my head around how to join these different data sets to get to my goal. How can I select the correct Dept value for each timesheet entry if I don’t have the exact matching dates on which I can join but just a date range?

  • 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-10T21:59:54+00:00Added an answer on June 10, 2026 at 9:59 pm
    SELECT
        t.Name,
        t.[Date],
        t.Hours,
        d.Dept
    FROM
        Timesheet t
        JOIN Department d
            ON t.Name = d.Name
            AND t.[Date] BETWEEN d.[From] AND d.To
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a small timesheet application. Timesheets have athletes, and each athlete has personal
I have a staff timesheet table where i have timestamp of when those records
I have a View with a table representing an employee's timesheet. Days across the
I am trying to create a timesheet and want to have the following SQL
I have a table which I want to update using a simple update command.
Basically I have a export from an old system with timesheets in it. Each
I am having a table (Table Name -Production) in SQL Server.The Production table have
I have a table(production) which is having a column with name TimeSpent, the datatype
I have a GridView using LinqDataSource to populate data from table Tickets . The
I have a Table Task with TaskId as Primary Key. And another table TimeSheet

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.