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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:04:51+00:00 2026-05-22T16:04:51+00:00

I am managing an event database. Every event has a start and end timestamp

  • 0

I am managing an event database. Every event has a start and end timestamp (INT, unix timestamp).

Currently i’m able to do the following things with a single SQL query:

  • build up a calendar, and mark days when an event occurring
  • list occurring events on a given date (YYYY/MM/DD, YYYY/MM)

The problem is when an event spans several days i can’t list it on a date between it’s start and end timestamps.

For example:

Event starts on 2011/05/25 and ends on 2011/05/27 i can’t list it on the page 2011/05/26.

My actual SQL query is

SELECT * FROM `event` 
WHERE (`start` BETWEEN ? AND ?) OR (`end` BETWEEN ? AND ?) 
ORDER BY start ASC

The two bound parameters (unix timestamps) are automatically calculated depending on what kind of parameter given (a whole month, or a specific day)

Is it possible to get these events (that spans several days) on a day between it’s two endpoints extending my query above?

Please let me know if i can clarify my question.

Update

Example:

event start: 1309125660 (2011-06-27 00:01:00)
end end: 1314050340 (2011-08-22 23:59:59)

select start: 1312408860 (2011-08-04 00:01:00)
select end: 1312495199 (2011-08-04 23:59:59)

This event won’t appear when i trying to list events occurring 2011/08/4

  • 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-22T16:04:51+00:00Added an answer on May 22, 2026 at 4:04 pm

    If I get the question right, with [:start, :end] being your date range of interest, you’re looking for:

    select *
     from event
    where -- event started earlier, ends later
          start <= :start and :start <= end
       or -- event starts during [:start, :end]
          :start <= start and start <= :end
       or -- event ends during [:start, :end]  
          :start <= end and end <= :end;
    

    If you’re looking for a particular :day, use :day as :start and :day + 1 day as :end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently managing multiple models from a single SITE MANAGER page. I have the
I'm currently managing some C++ code that runs on multiple platforms from a single
I'm managing an instance of Wordpress where the URLs are in the following format:
I'm managing an established site which is currently in the process of being upgraded
I read this article Managing Hierarchical Data in MySQL At the end of this
I have TableCellViewController for managing cells in my UITableView. Each cell has a label
I have a database that has lots of data and is all neat, normalized
I've been thinking of ways to improve managing changes to our database structure. I
I have inherited a Access database that has a query that SELECTs over 50
jQuery is firing on every mousemove event for me. How do I get it

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.