You can use Date ranges. If you have strings, you'll need to Parsedate
them into dates first. String ranges won't understand date overflow
(ie how many days in a month, months in a year etc.).
((1.year.ago.to_date)..(Date.today)).to_a.map{|x| x.to_s(:db)}
Julian
On 04/02/2009, at 4:55 PM, Shankar Ganesh wrote:
>
> hi,
>
> I've two dates say
>
> input for example.,
> date1 = '2009-01-02';
> date2 = '2009-01-10';
>
> Need to find date range array between date1 and date2.
>
> output for example.,
> Array{
> [0]=>'2009-01-02',
> [1]=>'2009-01-03',
> [2]=>'2009-01-04',
> [3]=>'2009-01-05',
> [4]=>'2009-01-06',
> [5]=>'2009-01-07',
> [6]=>'2009-01-08',
> [7]=>'2009-01-09',
> [8]=>'2009-01-10'
> )
> Thanks in advance
> Shankar.
> --
> Posted via http://www.ruby-forum.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 [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
-~----------~----~----~----~------~----~------~--~---