how to select distinct with an include?

Nice. Certainly more readable than my attempt.

Although the central issue here is we are using today as the starting
point - Chris was looking to use the start of the year.
What is missing is a "Time.now.start_of_year" method. I guess it would
be easy to add "start_of_day/week/month" methods as well to help with
these sorts of calculations. Then:
Time.mktime(2006,01,01) + 50.weeks
becomes
Time.now.start_of_year + 50.weeks.

Slightly better..

My other thought was:
Time.now.change(:month=>1, :mday=>1, :hour=>0).in(50.weeks)

Not as readable, but works and essentially captures the code for
"start_of_year".

:slight_smile:

irb(main):024:0> (Time.local(Time.now.year) + 50.weeks).monday
=> Mon Dec 11 00:00:00 -0500 2006
irb(main):025:0> (Time.local(Time.now.year) - 4.weeks).monday
=> Mon Nov 28 00:00:00 -0500 2005