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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:59:02+00:00 2026-06-13T12:59:02+00:00

We have weekly recurring events in our application, and have decided to store the

  • 0

We have weekly recurring events in our application, and have decided to store the start and end times for each event as the number of seconds from the beginning of the week (Sunday 12am). This makes querying, sorting, etc. much easier.

However, there is one small problem: If we want to get the event that is happening at a time near the week reset, that event could bridge that gap, and it makes querying difficult.

A normal query, which works 99% of the time, to grab the records where the given time is between the record’s start and end time.

time = 216000 # Tuesday, 12:00PM
SELECT * FROM events WHERE start_time <= 216000 AND end_time > 216000

The hard part is when there is an event that starts at, say, Saturday at 11pm, and ends on Sunday at 2am:

time = 3600 # Sunday, 1am
SELECT * FROM events WHERE start_time <= 3600 AND end_time > 3600

This won’t return anything because the start_time will NOT be less than 3600, since it starts near the end of the weekly cycle.

I’ve been racking my brain for a few hours trying to come up with a good solution, but have fallen short so far, so I’d like to open it up to SO to see if there is solution that I’m not thinking of. I have a feeling that there is some simple math equation I can use to get this done, but math isn’t my best subject 🙂

Please let me know if I need to explain better or give better examples.

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-06-13T12:59:04+00:00Added an answer on June 13, 2026 at 12:59 pm

    You can try something like:

    select * from events 
       where (start_time <= 3600 or start_time>end_time) and end_time > 3600; 
    

    This way you will be able to catch the events that were started before your rest time and are still happening at the specified time.

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

Sidebar

Related Questions

I have the update frequency of my ClickOnce application set to weekly. What is
We have set up a SharePoint meeting workspace (using WSS 3.0) for our weekly
I have a weekly script that moves data from our live database and puts
I'm new to git and I have a moderately large number of weekly tarballs
We have a number of integration tests that fail when our staging server goes
I am aware that questions about recurring events are common but I have not
I'm working a project that has recurring, weekly events. Thus, I use several DateTime
I'm trying to reschedule recurring events based on the recurring method: daily, weekly or
For our web development, we have daily to weekly deployments. There are instances where
I have a Rails application that generates a weekly report and emails it out.

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.