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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:58:54+00:00 2026-06-03T21:58:54+00:00

I want to create a query that will return all Alerts that have a

  • 0

I want to create a query that will return all Alerts that have a start time before “right now” and an end time after “right now”, and I only care about what time of day it is, not what date it is.

I would have thought this would work

Alert.find(:all, :conditions => [" ? between ? AND ?", Time.now, :start, :end])

However it does not because this query concerns itself with calendar dates, not just time of day.

I found “.to_s(:time)” but when I add that I get an error.

Alert.find(:all, :conditions => [" ? between ? AND ?", Time.now.to_s(:time), :start.to_s(:time), :end.to_s(:time)])

Alert.find(:all, :conditions => [" ? between ? AND ?", Time.now.to_s(:time), :start.to_s(:time), :end.to_s(:time)])
ArgumentError: wrong number of arguments(1 for 0)
        from (irb):48:in `to_s'
        from (irb):48
        from /home/chris/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
        from /home/chris/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
        from /home/chris/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:41:in `'
        from script/rails:6:in `require'
        from script/rails:6:in `'

How can I find all the of alerts that are active right now, based on now being between the start and end time of the Alert, irrespective of the calendar date of the start and end time? I am not currently thinking about time zones but will in the future.

  • 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-03T21:58:55+00:00Added an answer on June 3, 2026 at 9:58 pm

    This question represents a bug in ActiveRecord when using sqlite. The solution to this is to switch to mysql. More info here: https://github.com/rails/rails/issues/6247#issuecomment-5679856

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

Sidebar

Related Questions

I'm trying to create a query that will return all the jobs published by
I'm trying to create a MySQL query that will return all individual rows (not
I want a query that will return a row for each column in a
Im trying to create a function, that will return a mysql query, which i
Can anyonen help with Teradata? I want to create a query that is a
I want to create a query in TFS that allows me to view only
i want create image animation , i have 50 images with png format now
I'm trying to create a simple login system that will have the forms and
I want to make this kind of query: create procedure something @name varchar(13) as
I want DBSession.query(Article).group_by(Article.created.month).all() But this query can't using How do I do this using

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.