I'm writing a method that iterates using dates given a start and end date, and I need to the date within the loop. Something like this:
start_date = 2013/03/12
end_date = 2013/11/20
# from start_date to end_date do |f|
puts date_this_iteration_is_processing
end
Can someone please help me with this?
I've read these questions, but they didn't indicate how to determine the date that the given iteration is on.
How to Loop through Months in Ruby on Rails Iterating the dates in ruby on rails
is this what you are looking for?
use the range operator ..
start_date = Date.parse('2013-03-12')
end_date = Date.parse('2013-11-20')
(start_date..end_date).each do |day|
puts day
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With