Anyway..this is the only that returns valid results! thanks man!
it works even with 7.years.ago ! cool :)

so I'd need only to extract the year from the date params I get from
the form..and then maybe calculete how many years ago it is.
year(params[:date]) #?should this work?

:)

On 2 Ott, 14:39, Peter De Berdt <[email protected]> wrote:
> On 02 Oct 2009, at 13:12, adedip wrote:
>
> > I've this entry with a Date attribute, in the yyyy-mm-dd form.
>
> > I need to retrieve all the articles in a data Range, nothing of what I
> > read really worked..what's the matter?
>
> > Using find(:all, :conditions .... )
> > I've tryed:
> > - date between ? and ?
> > - date => from..to
> > - year(date)
>
> > nothing happened..is ruby able to evaluate range for Dates?
> > please show me the way :S
>
> If and only if your date field in the database is a date or a time:
>
> Model.all(:conditions => {:date => 7.days.ago..Date.today})
> Model.all(:conditions => ["date BETWEEN ? AND ?",  
> 7.days.ago ,Date.today])
>
> both generate and return valid results:
>
> SELECT * FROM `models` WHERE (`models`.`date` BETWEEN '2009-09-25  
> 12:35:21' AND '2009-10-02')
>
> I prefer the first notation, but tastes might differ.
>
> Best regards
>
> Peter De Berdt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to