On 02 Oct 2009, at 17:23, adedip wrote: > It could be good to me to only use year, so the question is how the > get only the year from a Date type? I've tryed year(date) but it does > not work (al least in the range actually)..or second aswer do I have > to write a method that calculates how many days ago I want? even for > 1993 ?
Model.all(:conditions => ["YEAR(date) BETWEEN ? AND ?", 2000 ,2010]) works perfectly on mysql. If your database doesn't support it, Model.all(:conditions => ["YEAR(date) >= ? AND YEAR(date) <= ?", 2000 ,2010]) might also work. Depends on whether you want an exact range from a certain date to a certain date or a range of years which option to choose. 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 -~----------~----~----~----~------~----~------~--~---

