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

  • Home
  • SEARCH
  • 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 177643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:05:26+00:00 2026-05-11T14:05:26+00:00

Given a time (eg. currently 4:24pm on Tuesday), I’d like to be able to

  • 0

Given a time (eg. currently 4:24pm on Tuesday), I’d like to be able to select all businesses that are currently open out of a set of businesses.

  • I have the open and close times for every business for every day of the week
  • Let’s assume a business can open/close only on 00, 15, 30, 45 minute marks of each hour
  • I’m assuming the same schedule each week.
  • I am most interested in being able to quickly look up a set of businesses that is open at a certain time, not the space requirements of the data.
  • Mind you, some my open at 11pm one day and close 1am the next day.
  • Holidays don’t matter – I will handle these separately

What’s the most efficient way to store these open/close times such that with a single time/day-of-week tuple I can speedily figure out which businesses are open?

I am using Python, SOLR and mysql. I’d like to be able to do the querying in SOLR. But frankly, I’m open to any suggestions and alternatives.

  • 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. 2026-05-11T14:05:27+00:00Added an answer on May 11, 2026 at 2:05 pm

    If you are willing to just look at single week at a time, you can canonicalize all opening/closing times to be set numbers of minutes since the start of the week, say Sunday 0 hrs. For each store, you create a number of tuples of the form [startTime, endTime, storeId]. (For hours that spanned Sunday midnight, you’d have to create two tuples, one going to the end of the week, one starting at the beginning of the week). This set of tuples would be indexed (say, with a tree you would pre-process) on both startTime and endTime. The tuples shouldn’t be that large: there are only ~10k minutes in a week, which can fit in 2 bytes. This structure would be graceful inside a MySQL table with appropriate indexes, and would be very resilient to constant insertions & deletions of records as information changed. Your query would simply be ‘select storeId where startTime <= time and endtime >= time’, where time was the canonicalized minutes since midnight on sunday.

    If information doesn’t change very often, and you want to have lookups be very fast, you could solve every possible query up front and cache the results. For instance, there are only 672 quarter-hour periods in a week. With a list of businesses, each of which had a list of opening & closing times like Brandon Rhodes’s solution, you could simply, iterate through every 15-minute period in a week, figure out who’s open, then store the answer in a lookup table or in-memory list.

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

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your code looks right (I haven't tested it), and the… May 12, 2026 at 1:03 am
  • Editorial Team
    Editorial Team added an answer Command-line scripting can be very useful, even in the Windows… May 12, 2026 at 1:03 am
  • Editorial Team
    Editorial Team added an answer Turns out the bindings were incomplete. It is now fixed.… May 12, 2026 at 1:03 am

Related Questions

Given a time (eg. currently 4:24pm on Tuesday), I'd like to be able to
For people suggesting throwing an exception: Throwing an exception doesn't give me a compile-time
I have 4 binary bits Bit 3 Bit 2 Bit 1 Bit 0 Normally
I would like to confirm that the following analysis is correct: I am building
I want to use a data structure for sorting space-time data (x,y,z,time). Currently a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.