Best way to get query by "from" date and "till date" is:
range = "created_at #{(12.months.ago..Time.today).to_s(:db)}"
Will result in creating String = "created_at BETWEEN "03-09-2006" AND "03-09-2007""
AND then
@data = MyModel.find(:all, :conditions => ["code=? AND #{range}", 2])
1 comment:
Muy buen ejemplo ra visualizar registros entre un rango de fechas utilizando created_at.
Post a Comment