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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:46:42+00:00 2026-06-06T05:46:42+00:00

I have a problem to solve. Here how it goes… An employee goes on

  • 0

I have a problem to solve. Here how it goes…

An employee goes on a leave or vacation and this entry is logged in a table with LEAVE_START_DATE and NO_OF_DAYS (which is number of business days).

A master table contains DATE, IS_WEEK_DAY (Y/N), IS_HOLIDAY (Y/N), and DAY_OF_WEEK.

It is required to generate a list of business dates on which the employee was on holiday.


Table leaves

LEAVE_START_DATE, NO_OF_DAYS    
2012-05-17, 3

Table days

DATE, IS_WEEK_DAY, IS_HOLIDAY, DAY_OF_WEEK
2012-05-17, Y, N, 5 
2012-05-18, Y, N, 6 
2012-05-19, N, N, 7 
2012-05-20, N, N, 1
2012-05-21, Y, Y, 2 
2012-05-22, Y, N, 3

Expected results

DATE
2012-05-17
2012-05-18
2012-05-22
  • 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-06T05:46:45+00:00Added an answer on June 6, 2026 at 5:46 am

    I must be oversimplifying – Are you asking to select the 3 days from table days (which is already populated) that matches the parameters of start date and business days? If so, the below will work. Also, you aren’t showing what version of SQL SERVER, so if it is before 2005 you will have to work around the parameterized TOP with ROWCOUNT or whatever you prefer.

    DECLARE @LeaveStartDate date, @noBusDays int
    SET @LeaveStartDate = '2012-05-17'
    SET @noBusDays = 3
    
    SELECT TOP (@noBusDays) [DATE] 
    FROM [DAYS]
    WHERE IS_WEEK_DAY = 'Y' 
    AND IS_HOLIDAY = 'N'
    AND [DATE] > = @LeaveStartDate
    ORDER BY [DATE]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem here I can't solve. I have a database of houses
I have an interesting problem here I've been trying to solve for the last
Ok, so here's the problem I have to solve. I need to write a
Here is a problem I am trying to solve: I have an irregular shape.
I'm trying to solve a problem that, unfortunately, goes beyond my capacity. I have
I have an interesting problem to solve here that may require some creative direction.
I'm not totally convinced this is possible, but here goes. I have a method
I'm not entirely sure how to post this question, but here goes... I have
I'm not sure if this is even possible, but here goes: I have a
I have a tough time trying to solve this problem. I have been at

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.