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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:32:51+00:00 2026-05-30T01:32:51+00:00

Attempting to create a filter select to find schedules with coursedates within a given

  • 0

Attempting to create a filter select to find schedules with coursedates within a given date range:

AdminController:

def find_schedules
  if params[:start_date] && params[:end_date]
   start_date = params[:start_date]
   end_date = params[:end_date]
   @schedules = Schedule.find(:all, :conditions => {:coursedate => start_date..end_date})
  redirect_to :action => 'find_results'  
  end
end

find_schedules view:

<% form_tag(find_schedules_path) do %>
<%= select_date Date.today, :prefix => :start_date %>
<%= select_date Date.today, :prefix => :end_date %>>
<%= submit_tag "Submit", :disable_with => "Submitting..." %>
<% end %>

Error:

    Processing AdminController#find_schedules (for ...) [POST]
  Parameters: {"start_date"=>{"month"=>"3", "day"=>"23", "year"=>"2011"}, "commit"=>"Submit", "authenticity_token"=>"...", "end_date"=>{"month"=>"2", "day"=>"16", "year"=>"2012"}}

ArgumentError (bad value for range)

I always seem to have trouble with date/datetime stuff. coursedate is a datetime field in the schedules table, if that makes any difference. I only need to search for dates, not times. Do I need to transform the data type somehow because of how mysql stores it? Or… what else am I doing wrong? Thanks in advance for your help.

Getting much closer after bdon’s help, thank you! Now I’m getting an undefined method error, but I should be able to figure that out:

ActionView::TemplateError (undefined method `each' for nil:NilClass) on line #26 of /admin/find_results.html.erb:       
25: <tr class="<%= cycle('odd', 'even') %>">
26: <% @schedules.each do |schedule| %>
  • 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-30T01:32:54+00:00Added an answer on May 30, 2026 at 1:32 am

    You’re getting this error because the “range” function doesn’t support hashes, which are being passed in this case:

    1.9.3-p0 :008 > {:year => 2012, :month => 11, :day => 1}..{:year => 2012, :month => 12, :day => 1}
    ArgumentError: bad value for range
    

    Instead you need to make the start and end of the range be DateTime objects:

    1.9.3-p0 :010 > DateTime.new(2012,11,1)..DateTime.new(2012,12,1)
    => Thu, 01 Nov 2012 00:00:00 +0000..Sat, 01 Dec 2012 00:00:00 +0000 
    

    So

    start_params = params[:start_date]
    start_date = DateTime.new(start_params["year"].to_i, start_params["month"].to_i, start_params["day"].to_i)
    

    Do the same for end_date.

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

Sidebar

Related Questions

I'm attempting to create a T-SQL case statement to filter a query based on
Some background: I am attempting to create a DirectShow source filter based on the
I'm attempting to create a regular expression to use as a filter in DeltaWalker.
I am attempting to create a DirectShow source filter based on the pushsource example
So I am attempting to create a search field that will filter contacts on
I am attempting to create a DirectShow source filter based on the pushsource example
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I'm currently attempting to create a tabbed interface in a web application, and based
I am attempting to create a small application to collect data received from an
I am attempting to create new membership users in an Ektron CMS400.NET-based website by

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.