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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:46:47+00:00 2026-05-25T13:46:47+00:00

I am having a hard time wrapping my head around this problem… I am

  • 0

I am having a hard time wrapping my head around this problem…

I am running an app with voting, and rather than having a new idea last for just 24 hours from the created_at date, I want the voting to start at the “next noon” and last for 24 hours.

i.e. if you created an idea at 8:00pm on a wednesday, people could vote on the idea until noon on Friday (24 hours after the next noon). Or if you created an idea at 11:50am on thursday, you would also have until noon on Friday to vote.

So basically I just need to find a way to make an instance… say:

     @recentideas = current.user.ideas.where(:created_at => (nextnoontime)...(nextnoontime + 24.hours))

I acknowledge that the above is not actual code, but just to put it into perspective…

Thanks in advance.

Update with soultion:

It turns out the easier solution (not exactly elegant) was to say:

     <% if idea.created_at.hour < 12 %>
       <% @nextnoon = idea.created_at.midnight + 12.hours %>
       <% @timedif = @nextnoon - idea.created_at %>
     <% else %> 
       <% @nextnoon = idea.created_at.tomorrow.midnight + 12.hours %>
       <% @timedif = ((@nextnoon - 12.hours) - idea.created_at) + 12.hours %>
     <%end%>

And then the related if statement was:

     <% if idea.created_at > ((24.hours + @timedif)/3600).hours.ago %>

A bit clunky, but I’ll clean it up at a later date.

  • 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-25T13:46:47+00:00Added an answer on May 25, 2026 at 1:46 pm

    You can find noon of the ending day like so

    now = DateTime.now
    twelve_hours_from_now = now + 12.hours
    beginning_of_day = DateTime.new(twelve_hours_from_now.year, twelve_hours_from_now.month, twelve_hours_from_now.day)
    noon_of_ending_day = beginning_of_day + 36.hours
    

    So your query would be

    @recentideas = current.user.ideas.where(:created_at => (now...noon_of_ending_day))
    

    although that query doesn’t make too much sense as no ideas will have been created between now and some time in the future. We are still waiting for those ideas to appear.

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

Sidebar

Related Questions

I'm having a very hard time wrapping my head around this problem (it might
I'm having a hard time wrapping my head around this and need some help
I'm having hard time wrapping my head around this. I have an array called
I'm having a hard time wrapping my head around this, and I'm hoping someone
Having a hard time wrapping my head around this one. I have a Page
I'm having a hard time wrapping my head around this. I'm loading up an
I am still having a hard time wrapping my head around this. I want
i am having a hard time wrapping my head around how to do this...
I'm having a hard time wrapping my head around this Django query. I could
I'm having a hard time wrapping my head around Java generic types. Here's a

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.