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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:30:33+00:00 2026-05-13T09:30:33+00:00

I have a list of storecodes in table Stores and another table StoreClosedDates which

  • 0

I have a list of storecodes in table “Stores” and another table “StoreClosedDates” which tells me if the store is closed on a Saturday or Sunday. My StoreOpenDates table looks like this:

CREATE TABLE [dbo].[StoreClosedDates](
    [StoreCode] [varchar](50) NOT NULL,
    [ClosedOnSunday] [bit] NOT NULL,
    [ClosedOnSaturday] [bit] NOT NULL
) ON [PRIMARY]

This table needs to be changed later to include holiday dates as well, so that those can be covered as well. I am not entirely surely how I can change this table to cover both options (holidays and weekends). Now I need to write a query which returns me a list of stores that are open for the current date. I am not sure how to compare for the weekend in the where clause – I know I should be using: DATEPART ( dw , getdate() ), but I cant seem to see the entire picture to solve it.

The StoreClosedDates contains only stores that closed. If a store is not present in that table, then the store is open for the current date.

  • 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-13T09:30:33+00:00Added an answer on May 13, 2026 at 9:30 am
    SELECT  *
    FROM    StoreClosedDates
    WHERE   NOT (DATEDIFF(day, GETDATE(), '2007/01/01') % 7 = 5 AND ClosedOnSaturday = 1)
            AND NOT (DATEDIFF(day, GETDATE(), '2007/01/01') % 7 = 6 AND ClosedOnSunday = 1)
    

    Better avoid usage of DATEPART, because it’s locale dependent.

    To check for the fixed date holidays, create a table with two separate columns containing the month and the date:

    CREATE TABLE holiday (
            hmon TINYINT, hday TINYINT,
            PRIMARY KEY (hmon, hday),
            CHECK(CAST('2008-' + CAST(hday AS VARCHAR) + '-' + CAST(hmon AS VARCHAR) AS DATETIME) > 0)
            )
    

    and use it in a query:

    SELECT  *
    FROM    Stores
    WHERE   id NOT IN
            (
            SELECT  StoreID
            FROM    StoreClosedDates
            WHERE   NOT (DATEDIFF(day, GETDATE(), '2007/01/01') % 7 = 5 AND ClosedOnSaturday = 1)
                    AND NOT (DATEDIFF(day, GETDATE(), '2007/01/01') % 7 = 6 AND ClosedOnSunday = 1)
            )
            AND NOT EXISTS
            (
            SELECT  NULL
            FROM    Holidays
            WHERE   hday = DAY(GETDATE())
                    AND hmon = MONTH(GETDATE())
            )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have a look at UpdatePanel control UpdatePanel Control Overview UpdatePanel… May 13, 2026 at 7:23 pm
  • Editorial Team
    Editorial Team added an answer Try this, using mkdir: if (!file_exists('path/to/directory')) { mkdir('path/to/directory', 0777, true);… May 13, 2026 at 7:23 pm
  • Editorial Team
    Editorial Team added an answer Forgot to add the files to QT Designer. Solved! May 13, 2026 at 7:23 pm

Related Questions

I have a list of integers, List<Integer> and I'd like to convert all the
I have a List of Foo. Foo has a string property named Bar. I'd
I have a list of 2-item tuples and I'd like to convert them to
I have a list of more than 15 thousand latitude and longitude coordinates. Given
I have a list of objects I wish to sort based on a field

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.