I have a Rails named_scope that uses a condition to pull certain days of the week from a table as follows:
:conditions => [ 'EXTRACT(DOW FROM bookdate) IN (?)', (1..6).to_a ]
The date range 1..6 will be variable depending on the dates that the user wants,
What creates this SQL
(EXTRACT(DOW FROM bookdate) IN (1,2,3,4,5,6)
My problem is that the days of the week are not a simple range ... i.e. 1..6 works fine (Mon ... Sat), but let's say that 6..2 will not work correctly (Sat-W) ... either as a ruby โโrange, or as it should be 6,7,1, 2, and not 6,5,4,3,2 (provided that 6,2 worked in a ruby, which is not).
How do I create a custom range for the days of the week that matches a date range like this?
Any ideas?
Thank,