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 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/Numeric/Time.html http://rubyforge.org/projects/chronic/ http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M000572 HTH On 1 Feb., 21:50, John Paul <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 > > -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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
On 2/1/07, John Paul
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> 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
>
> --
> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---