"date") What I want to do is find the specific records that have been use...">

Rails 2.3.5 - The ".find" function does not work with (: condition => "date")

What I want to do is find the specific records that have been used in the last 60 days.

I am using Oracle (9i), Rails v: 2.3.5, Ruby v: 1.8.7

My code for determining the date interval:

date =(((Time.now - 60.days).strftime("%d-%b-%y"))...(Time.now.strftime("%d-%b-%y")))

and here is how I use it:

conditions = {}
conditions[:start_date] = date
conditions[:account_no] = account_number

results = MyModel.find(:all, :conditions => conditions)

To see what is selected, I basically do:

results.each {|r|
  if (!(r.column_name.nil?))
     #do something here
  end
}

Result: The code works, but the "results" are empty

However, when I copy and paste the query generated by "MyModel.find ..." into sqlDeveloper, I can finally see what I want.

What should be the reason why I cannot get the same results with SQL Developer, although I am using the same query that is generated by the above code.

+4
1

, start_date Date

date =((DateTime.now - 60)...(DateTime.now))
conditions = {}
conditions[:start_date] = date
conditions[:account_no] = account_number

results = MyModel.find(:all, :conditions => conditions)

, , .

, date.to_a, , .

date.to_a, 60 , . IN SQL

+1

All Articles