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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:39:15+00:00 2026-05-23T12:39:15+00:00

I have a table called events with 5 fields. Among those fields I have

  • 0

I have a table called events with 5 fields. Among those fields I have the eventDate field (date type field) in which I keep the date when the event will take place.

I made a dropdown with options to select from the events table.
1. All events (contains just the events from today and from the future, excluding those from the past)
2. Events this week
3. Events next week
4. Events next month

Can smbd help me with the SELECT statements for this, in MYSQL?

  • 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-23T12:39:16+00:00Added an answer on May 23, 2026 at 12:39 pm
    function x_week_range($date) {
                    $ts = strtotime($date);
                    $start = (date('w', $ts) == 0) ? $ts : strtotime('last sunday', $ts);
                    return array(date('Y-m-d', $start),
                                             date('Y-m-d', strtotime('next saturday', $start)));
            }
    
    
            //all events
    
    
            $sql = "SELECT * FROM events WHERE eventDate>='".date("Y-m-d")."' ";
            echo $sql."<br />";
    
    
            //current week 
    
            list($start_date, $end_date) = x_week_range(date("Y-m-d"));
    
            $sql = "SELECT * FROM events WHERE eventDate>='$start_date' AND eventDate<'$end_date'";
            echo $sql."<br />";
    
    
            //next week 
            $nextweek  = mktime(0, 0, 0, date("m")  , date("d")+7, date("Y"));
            $nextweek_day =  date("Y-m-d",$nextweek);
    
    
            list($start_date, $end_date) = x_week_range($nextweek_day);
    
            $sql = "SELECT * FROM events WHERE eventDate>='$start_date' AND eventDate<'$end_date'";
            echo $sql."<br />";
    
            //next month
            $m = date("m");
            $y = date("Y");
    
            $start_date = date("Y-m-d", mktime(0,0,0,$m+1,1,$y));
            $end_date = date("Y-m-d", mktime(0,0,0,$m+2,1-1,$y));
    
            $sql = "SELECT * FROM events WHERE eventDate>='$start_date' AND eventDate<'$end_date'";
            echo $sql."<br />";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table called Event. A column has duration--which is...how long that event
I had a mysql table called events with the fields: id, date, and name.
Given a table Event containing a field called EventTime of type DateTime and that
I have a table called BlogPost which has a 1-to-many relationship with the Comment
i have a table called category in which i have main category ids and
My application has one table called 'events' and each event has approx 30 standard
I have a table called participants that has 3 fields: prt_id prt_event_id prt_participant_id What
I have two tables called 'events' and 'topics' each table can have many comments.
Hey there, i have a table with a field called file full of binary
I have a table called Events that I want to insert information to. Here

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.