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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:55:32+00:00 2026-05-24T16:55:32+00:00

I want to search data within the given date range. I have a database

  • 0

I want to search data within the given date range. I have a database with having details of name, venue, start_at and end_at. I can search name and venue by defining find method in controller.following is my controller code.

def find
  @events=Event.find(:all, :conditions=>["venue = ? OR name = ?", params[:search_string], params[:search_string]])
end

Then it will find venue or name. But when I add start_at into this code it will return an exception. how can i search relevant date range from the database? plz anybody can help me? I am using postgresql and ruby 1.8.7 and rails 2.3.8 versions.

I changed my find method as follows…

def find    
  if (params[:search_string])
    @events=Event.find(:all, :conditions=>["venue = ? OR name = ?", params[:search_string], params[:search_string]])
  else 
    @events= Event.all(:conditions => ["start_at >= ? AND end_at <= ?",  params[:start_at], params[:end_at]])
  end
end                                                           

first if statement was properly working. but else part is not working. there is no exception. it will not retrieve date related data from database. I add this if statement into my code due to not retrieving data. can anybody help me to correct this second part? I enter date in my search textbox. but it will not retrieve any data.

  • 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-24T16:55:33+00:00Added an answer on May 24, 2026 at 4:55 pm

    I could find a way to search a data within given date range. I did this separately.I created two text_field_tag in my layout and created controller code as follow.

        def find
        @events= Event.all(:conditions => ["start_at >= ? AND end_at <= ?",  params[:search], params[:search_string]])
    
        end
    

    Then I added following code in layout.

        <span style="text-align: right">
        <% form_tag "/events/find" do %>
        <%= text_field_tag :search%>
        <%= text_field_tag :search_string %>
        <%= submit_tag "search" %>
        <% end %>
        </span>
    

    I got data from database.. Now I want to combine these two. finding a data by date range needs two text_field_tag and finding a data by name only need one text_field _tag. So how can I do this? need your help further more….

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

Sidebar

Related Questions

I want to create search interface to search data from GAE datastore? Can i
Hi, i have been having some problems using JSON data in flash builder lately
I have a search form field that I want to compare with multiple columns
I want to create binary search tree data structure in C/C++ where each node
I have 2 tables containing information that I want to search for, a main
We have an MS Access 2007 database with a simple form displaying table data.
I have some reference data in a text file (~5MB) that I want to
Consider this: One mySQL database that has tables and rows and data within it.
I am scraping data from I want to scrape three search engines. In My
I want to search for files containing DOS line endings with grep on Linux.

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.