> I have a class Day with field date that represents a my sql date type,
> YYYY-MM-DD. The Ruby type Date class has method, cweek, that returns
> the calendar week that corresponds to a particular date. Ruby knows
> cweek, but MySQL has no knowledge of this value. How do I run a find on
> class Day, (Day.find :all ... ) with condition [date.cweek = ?, week]?
> This is not a sql search but a Ruby search of all Day objects and their
> corresponding date.cweek attribute.
>
> How do I write this find method call?
MySQL has WEEK and WEEKOFYEAR functions, latter being equivalent to WEEK(date,3)
so your condition might look like [WEEKOFYEAR(date) = ?,week].
Be sure to check if weekofyear is what you want, maybe you should use
week with different mode (second parameter).
And, of course, this is MySQL specific.
Regards,
Rimantas
--
http://rimantas.com/
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---