Hi, I need to be able to add one month or in some cases on eyear to a Date. Does anyone know of any easy ways of doing this? thanks scott -- Posted via http://www.ruby-forum.com/.
Yo! Try: @date_object = ''12-02-2002''.to_date @date_object_one_year_later = @date_object + 365 Ciao Gustav Paul gustav@rails.co.za itsdEx.com -- Posted via http://www.ruby-forum.com/.
>> now = Time.now=> Fri Jul 28 10:56:44 Eastern Standard Time 2006>> now.next_month=> Mon Aug 28 10:56:44 Eastern Standard Time 2006>> now.next_year=> Sat Jul 28 10:56:44 Eastern Standard Time 2007 On 7/28/06, dave <dave@streadm.net> wrote:> > Hi, > > I need to be able to add one month or in some cases on eyear to a Date. > > Does anyone know of any easy ways of doing this? > > thanks > scott > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060728/d6f3b124/attachment.html
Well, doesn''t get any easier than that! _____ From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Jeremiah Peschka Sent: Friday, July 28, 2006 10:57 AM To: rails@lists.rubyonrails.org Subject: Re: [Rails] add one month or one year to a date>> now = Time.now=> Fri Jul 28 10:56:44 Eastern Standard Time 2006>> now.next_month=> Mon Aug 28 10:56:44 Eastern Standard Time 2006>> now.next_year=> Sat Jul 28 10:56:44 Eastern Standard Time 2007 On 7/28/06, dave <dave@streadm.net> wrote: Hi, I need to be able to add one month or in some cases on eyear to a Date. Does anyone know of any easy ways of doing this? thanks scott -- Posted via http://www.ruby-forum.com/. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060728/9ce77516/attachment.html
A lot of these are documented in the Time class, there are some great methods in there like Time.at_beginning_of_day, Time.at_beginning_of_month, Time.seconds_since_midnight, etc,etc,etc On 7/28/06, Michael Scappa <mscappa@verveinternet.com> wrote:> > Well, doesn''t get any easier than that! > ------------------------------ > > *From:* rails-bounces@lists.rubyonrails.org [mailto: > rails-bounces@lists.rubyonrails.org] *On Behalf Of *Jeremiah Peschka > *Sent:* Friday, July 28, 2006 10:57 AM > *To:* rails@lists.rubyonrails.org > *Subject:* Re: [Rails] add one month or one year to a date > > > > >> now = Time.now > => Fri Jul 28 10:56:44 Eastern Standard Time 2006 > >> now.next_month > => Mon Aug 28 10:56:44 Eastern Standard Time 2006 > >> now.next_year > => Sat Jul 28 10:56:44 Eastern Standard Time 2007 > > On 7/28/06, *dave* <dave@streadm.net> wrote: > > Hi, > > I need to be able to add one month or in some cases on eyear to a Date. > > Does anyone know of any easy ways of doing this? > > thanks > scott > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060728/df77d87a/attachment.html