trouble adding date query variable

L

laredotornado

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
 
I

Ilan Berci

laredotornado said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top