Hi all,
Which method is used to calculate the days between two dates spanning
different years?
Thanks,
Li
Hi all,
Which method is used to calculate the days between two dates spanning
different years?
Thanks,
Li
Li Chen [email protected] wrote:
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 F.
Jan F. wrote:
require ‘date’
=> falsed1 = 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
=> 203Regards,
Jan F.
Thank you so much,
Li
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs