On 21 Sep 2009, at 17:05, juanmac wrote:

>
> Hi all!
>
> I have a table with the birthdays of users and I want my app to list
> all users who birthdays today.
>
> If today is 21/09/2009, I need all the rows which have the field
> b_date 21/09.
>
> How can I get that condition in ActiveRecord?
> Should I try something like this:
>
> @birthdays = Birthday.find(:all, :conditions => {:b_date.day =>
> Date.today.day, :b_date.month => Date.today.month})
>
> I'm a newbie so excuse me if this question is to much easy and excuse
> my poor english too...
>
You can't do it quite like that. You need to turn what you want into  
something of the form

start_time <= b_date and b_date < end_time

(so start_date is probably the first second of today and end_time is  
the first second of tomorrow)

You can't use the hash form of conditions for this.

Fred
> Thanks in advance.
> >


--~--~---------~--~----~------------~-------~--~----~
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