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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:32:34+00:00 2026-05-26T08:32:34+00:00

I am selecting records from my table that have been posted within the past

  • 0

I am selecting records from my table that have been posted within the past day. This is for an internal site, where there are no posts on Saturdays or Sundays.

SELECT * 
FROM table 
WHERE date >= DATE_SUB(CURDATE(), INTERVAL 1 DAY)

This works fine if today is a weekday or Saturday (where the previous day is Friday). If today is Sunday, I’d like to get records for Friday but currently my code shows records for Saturday (which are obviously blank, given that no one posts on Saturday). How can I fix that?

Thanks!

  • 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-26T08:32:34+00:00Added an answer on May 26, 2026 at 8:32 am

    Have a look at the WEEKDAY operator. It returns the index of the day in the week.
    0 = Monday and 6 = Sunday

    SELECT * 
    FROM table 
    WHERE date = CASE WEEKDAY(CURDATE())                 -- Switch on day index
        WHEN 6 THEN DATE_SUB(CURDATE(), INTERVAL 2 DAY)  -- If sunday, back 2 days
        WHEN 0 THEN DATE_SUB(CURDATE(), INTERVAL 3 DAY)  -- If monday, back 3 days
        ELSE DATE_SUB(CURDATE(), INTERVAL 1 DAY)         -- Else back 1 day
        END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table showing records from database. There is a dropdown for selecting
I have a page that inserts records into a table. what i am having
I'm selecting a set of account records from a large table (millions of rows)
I have users selecting a DateTime using a caldendar/clock popup that allows them to
I'm selecting products from a database table. Currently the query is launched from Coldfusion,
I have been tasked with returning a negative selection from our sql database. I'll
I am confused about selecting two approaches. Scenario there are two tables Table 1
I have two jobs pulling from a mysql table. They both want to get
I have a query that's selecting a bunch of fields related to names and
Is there a way in MySQL to COUNT(*) from a table where if the

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.