Forum: Ruby on Rails Twice select_date -> Date range

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
520c24bad2fa9b171d022e3600cd5e58?d=identicon&s=25 Mark Noten (mnoten)
on 2007-01-15 23:25
Hi all,

I'm using twice the select_date function in my view to select a date
from and a date until for a date property in my model called

<p><label for="proposal_written_from">Written between</label><br/>
<%= select_date nil, :prefix => "written_from",
  :order => [:day, :month, :year],
  :include_blank => true %></p>

<p><label for="proposal_written_until">and</label><br/>
<%= select_date, :prefix => "written_until",
  :order => [:day, :month, :year],
  :include_blank => true %></p>

In my model, I want to create a date range if the user has selected
valid values for both the date written_from and the date written_until.
The POST parameters for written_from and written_until look like this:

Parameters: {"commit"=>"Find", "written_until"=>{"month"=>"1",
"day"=>"20", "year"=>"2007"}, "action"=>"find_proposals",
"controller"=>"proposals", "proposal"=>{"client_firstname"=>"",
"client_surname"=>"", "city"=>"", "box"=>"", "postal_code"=>"",
"number"=>"", "units"=>"", "policy_number"=>"", "street"=>"",
"agent_id"=>""}, "written_from"=>{"month"=>"1", "day"=>"2",

Basically I just want to create a range like (date_from..date_until)
that I can use with the ez_where plugin for a SQL BETWEEN condition.

I tried to create the dates like this:

written_from = Date.civil(p[:written_from][:year],
p[:written_from][:mon], p[:written_from][:day])
written_until = Date.civil(p[:written_until][:year],
p[:written_until][:mon], p[:written_until][:day])

but that doesn't seem to work. The ez_where condition would look
something like:

cond = do
  written_on <=> (date_from..date_until) unless date_from.nil? ||

Can anybody help me out with this? The ez_where plugin can be found at

Thanks for your reply,

This topic is locked and can not be replied to.