I am trying to subtract on date from the other to find how many days
have passed.
I want to know what I need to do to determine
date_sent = 2007-01-01
date_now = Date.today
I want to be able to subtract the date_sent from date_now and return the
accurate number of days that have passed. Does anyone know how to do
this? I also what to make sure it actually accounts for months being an
uneven number of days.
Thanks
JP
Hi
number_of_days = (date_now - date_sent).to_i
btw, didn’t know this but, Data.parse(“2007-01-01”) returns the date
works great in the console.
regards
Ivor
date_sent = Date.parse(“2007-01-01”)
date_now = Date.today
days_passed = (date_now - date_sent).to_i
Subtracting two dates gives a Rational which is the reason for the
integer conversion.
On Feb 1 2007, 1:50 pm, John P. [email protected]
Rob Olson wrote:
Subtracting two dates gives a Rational which is the reason for the
integer conversion.
why does it return a Rational type?
I have done something similar::
date_sent = Date.parse(‘2007-01-01’)
date_now = Date.today
how_many_days_have_passed = (date_now - date_sent).to_i
Hope this helps!
On Feb 1 2007, 1:50 pm, John P. [email protected]