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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:28:32+00:00 2026-05-23T07:28:32+00:00

I have a table that contains an id field along with 5 fields, one

  • 0

I have a table that contains an id field along with 5 fields, one for each week-day from Monday to Friday, where datatype is bit.

The table looks something like:

+---+--------+---------+-----------+----------+--------+
|id | Monday | Tuesday | Wednesday | Thursday | Friday |
+---+--------+---------+-----------+----------+--------+
| 1 |      1 |       0 |         0 |        0 |      0 |
+---+--------+---------+-----------+----------+--------+
| 2 |      1 |       0 |         0 |        0 |      0 |
+---+--------+---------+-----------+----------+--------+
| 3 |      0 |       0 |         0 |        1 |      0 |
+---+--------+---------+-----------+----------+--------+
| 4 |      1 |       0 |         0 |        0 |      1 |
+---+--------+---------+-----------+----------+--------+

Depending on the day I’m trying to return the rows that have the bit set to true for that day. I was thinking of doing this with a where clause but can’t get it to work.

I think there is something wrong in my logic, any help is greatly appreciated!

DECLARE @tDay as INTEGER
SET @tDay = datepart(weekday, getdate())

SELECT     id, monday, tuesday, wednesday, thursday, friday
FROM         Days
WHERE   CASE WHEN @tDay = 2 then @tDay 
        Else Days.monday
        End = 1
        AND 
        CASE WHEN @tDay = 3 then @tDay 
        Else Days.tuesday
        End = 1 
  • 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-23T07:28:32+00:00Added an answer on May 23, 2026 at 7:28 am

    This will work if SET DATEFIRST is 7. You need to adjust if you have some other day as first day of the week.

    DECLARE @tDay as INTEGER
    SET @tDay = datepart(weekday, getdate())
    
    select id, monday, tuesday, wednesday, thursday, friday
    from Days
    where case @tDay
            when 2 then monday
            when 3 then tuesday
            when 4 then wednesday
            when 5 then thursday
            when 6 then friday
          end = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy MS Access 2007 table that contains 52 fields (1 field
I have a table that contains members names and a field with multiple ID
I have an SQL Server 2005 table that has a varchar(250) field which contains
I have a table that contains some blob fields that I don't want to
I have a database table TravelRequest that contains, amongst other things, the fields SignOffName
I have a database structure that has a Person table which contains fields such
Greetings. I have files that contains eleven fields in the file name. Each file
I have an mnesia table t that contains records with a single field x
I have a table with a field that contains a bunch of neighborhood names.
I have a table that contains a text field, there is around 3 to

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.