Hi all,
Which method is used to calculate the days between two dates spanning
different years?
Thanks,
Li
···
--
Posted via http://www.ruby-forum.com/.
Hi all,
Which method is used to calculate the days between two dates spanning
different years?
Thanks,
Li
--
Posted via http://www.ruby-forum.com/.
Which method is used to calculate the days between two dates spanning
different years?
Something like this:
require 'date'
=> false
d1 = Date.new(2009, 8, 12)
=> #<Date: 4910111/2,0,2299161>
d2 = Date.new(2010, 3, 3)
=> #<Date: 4910517/2,0,2299161>
d2 - d1
=> Rational203, 1
(d2 - d1).to_i
=> 203
Regards,
Jan Friedrich
Li Chen <chen_li3@yahoo.com> wrote:
Jan Friedrich wrote:
require 'date'
=> false
d1 = Date.new(2009, 8, 12)
=> #<Date: 4910111/2,0,2299161>
d2 = Date.new(2010, 3, 3)
=> #<Date: 4910517/2,0,2299161>
d2 - d1
=> Rational203, 1
(d2 - d1).to_i
=> 203
Regards,
Jan Friedrich
Thank you so much,
Li
--
Posted via http://www.ruby-forum.com/\.