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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:55:04+00:00 2026-06-16T01:55:04+00:00

I have two tables: Holiday and EmpLog I need to select only the dates

  • 0

I have two tables:

Holiday and EmpLog

I need to select only the dates that are not present in Emplog (those days are WEEKDAYS and NOT equal to Holidays ONLY)

For example, I haven’t logged this day: Dec 18, 2012.

So the output will be dec 18,2012

  • 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-16T01:55:07+00:00Added an answer on June 16, 2026 at 1:55 am

    From the question, I assume the following:

    1. You have an EmpLog table, that has the datestamp of all the dates the Employee was present.
    2. You have a Holiday table that has a list of dates that were either Weekends or Holidays
    3. You need to find out all the dates that were working days, but a given employee was not logged

    If these assumptions are correct, then this code will work:

    --Declare variables to hold date values 
    DECLARE @MyDate    DATETIME, 
            @FirstDate DATETIME, 
            @LastDate  DATETIME 
    
    SELECT @MyDate = Getdate() -- OR Pass whatever date you want 
    
    --Populate variable with values of first date and last date of the given month 
    SELECT @FirstDate = CONVERT(VARCHAR(25), Dateadd(dd, -( Day(@mydate) - 1 ), 
                                             @mydate), 
                               101), 
           @LastDate = CONVERT(VARCHAR(25), Dateadd(dd, -( Day( 
                                            Dateadd(mm, 1, @mydate)) ), 
                                                        Dateadd(mm, 1, @mydate)), 
                       101) 
    
    --Declare table variable to hold date values for the entire month 
    DECLARE @AllDates TABLE 
      ( 
         datevalue DATETIME 
      ) 
    DECLARE @Lastday INT 
    
    SET @Lastday = Datepart(d, @LastDate) 
    
    DECLARE @Days INT 
    
    SET @Days = 1 
    
    -- Populate table variable with all days of the month 
    WHILE @Days <= @Lastday 
      BEGIN 
          INSERT INTO @AllDates 
          SELECT @FirstDate 
    
          SET @FirstDate = Dateadd(d, 1, @FirstDate) 
          SET @Days = @Days + 1 
      END 
    
    --Query joining the EmpLog table and Holiday Table, using Left Outer Join  
    SELECT AD.datevalue 
    FROM   @AllDates AD 
           LEFT OUTER JOIN emplog EL 
                        ON AD.datevalue = EL.datevalue 
           LEFT OUTER JOIN holiday H 
                        ON AD.datevalue = H.datevalue 
    -- Where clause to return only dates that do not appear in EmpLog or Holiday tables 
    WHERE  EL.datevalue IS NULL 
           AND H.datevalue IS NULL  
    

    Hope this helps.

    Rajan

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables that have the same structure, I need a query to
I have two tables: CalendarEntry Id Date ... Holiday Id Date ... In my
I have two tables named User, Holiday. Now my objective is to search user.
I have two tables listings and bids. I have a query that will return
Have two tables: CREATE TABLE IF NOT EXISTS `issue_details` ( `id` INT NOT NULL
I have two tables in the system. I'm trying to make a VIEW that
I have two tables ITEMS : id, name CATEGORIES: items_id, category I need to
I have two tables, users and visits. I want to select all users who
I have two tables named utilities and types that i am trying to access
I have two tables that I want to use for viewing my reports which

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.