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.