laredotornado wrote:
> Hi,
> 
> I'm trying to build a search form with a date input field, displayed
> like this:
> 
> <%= date_select(:purchase_date, params[:purchase_date]) %>
> 
> But I'm having trouble adding the criteria in my controller.  So far,
> I have:
> 
>                 if !search[:purchase_date].blank?
>                         conditions << 'purchase_date >= ?'
>                         conditions << "#{search[:purchase_date]}"
>                 end
>                 find(:all, :conditions => conditions, :page => {:size
> => page_size, :current => page_num} )
> 
> But the query gets run in a weird way, below:
> 
> SELECT count(ec_orders.id) AS count_ec_orders_id FROM `ec_orders`
> WHERE purchase_date >= '(3i)24(1i)2006(2i)2')
> 
> 
> What is the right way to get the date to be displayed normally in the
> SQL query? - Dave

conditions => ["purchase_date >= ?", search[:purchase_date].to_s(:db)]

hth

ilan
-- 
Posted via http://www.ruby-forum.com/.