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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:29:42+00:00 2026-06-02T17:29:42+00:00

I have a table containing a list of events with a start date and

  • 0

I have a table containing a list of events with a start date and an end date. I can successfully get a list of events occurring today with the following:

SELECT * FROM event WHERE CURDATE() BETWEEN start_date and end_date

Or a list of events occurring exactly one week from today with the following:

SELECT * FROM event WHERE DATE_ADD(CURDATE() INTERVAL 1 WEEK) BETWEEN start_date and end_date

But, I want a list of events occurring anytime between today and one week from today (inclusive). Keep in mind, each event spans multiple days and is defined by a start date and end date, not a single day event.

Is there a simple way to query for this, or would it be easier to just loop through each day in PHP with the first query above (replacing CURDATE with each day from today through one week from now)?

  • 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-02T17:29:45+00:00Added an answer on June 2, 2026 at 5:29 pm

    I like to visualize problems like this. As far as I understand your question, there are four types of events that should be returned:

              |-------------------- WEEK ---------------------|
              |                                               |
              |         |========== EVENT ==========|         |
         |========== EVENT ==========|                        |
              |                        |========== EVENT ==========|
         |========================= EVENT =========================|
              |                                               |
              |-----------------------------------------------|
    

    This means that we have:

    • events that start and end in the week;
    • events that start before the week and end in the week;
    • events that start in the week and end after the week;
    • events that start before the week and end after the week.

    Translating this into SQL gives the following:

    SELECT *
    FROM events
    WHERE (start_date >= CURDATE() AND end_date <= CURDATE() + INTERVAL 1 WEEK)
       OR (start_date < CURDATE() AND end_date >= CURDATE() )
       OR (start_date <= CURDATE() + INTERVAL 1 WEEK 
          AND end_date > CURDATE() + INTERVAL 1 WEEK)
       OR (start_date < CURDATE() AND end_date > CURDATE() + INTERVAL 1 WEEK);
    

    I used >= and <= for the dates within the one-week period. This way we make sure that events that start or end on the start or end of the one-week period are included as well.


    Assuming that start_date <= end_date is true for all rows, the simpler method is:

    SELECT *
    FROM events
    WHERE start_date <= CURDATE() + INTERVAL 1 WEEK 
      AND CURDATE() <= end_date 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing date , employeeID (int) , and ShiftWorked (can be
I have a table containing a series of names, events and dates. I've created
I have a table containing reports and the date/time they were created. I'd like
I have a table containing cells with phone numbers. How can I allow the
I have a table containing 2 date fields and an identifier (id, fromdate and
I currently have a code table containing a list of types (Type_ID, Description), but
I have a table with a Name field containing data similar to the following:
I have a table lists containing list information like title and id (auto_increment) and
Say I have a table called students, containing a list of all the students.
I have a table with a column containing a list (yes I know this

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.