From: Glen Holcomb Date: 2007-07-04T00:12:03+09:00 Subject: Re: How do I add x months to a date ------=_Part_89893_1325410.1183475524836 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline And when I say string you could do better and use a hash or an array. On 7/3/07, Glen Holcomb wrote: > > You can't do it directly, date objects are immutable. > > You could always get the date value from the object and then parse it, add > the number of months you want and then create a new date object. That > seems > like a bit of a waste though. I would keep the date value in a string and > manipulate it there, if and when I needed an actual date object with that > value I would create a date object and give that out. > > On 7/3/07, Ben Edwards wrote: > > > > I have a date > > > > my_date = Date.new( 2007, 1, 1 ) > > > > I then have a variable holding an integer > > > > months_to_add = 4 > > > > How do i add 'months_to_add' to my_date'? > > > > I have spent ages googeling and looking in o'reilly ruby cookbook but no > > luck;( > > > > Any ideas? > > > > Ben > > -- > > Ben Edwards - Bristol, UK > > If you have a problem emailing me use > > http://www.gurtlush.org.uk/profiles.php?uid=4 > > (email address this email is sent from may be defunct) > > > > > > > -- > "Hey brother christian with your high and mighty errand, Your actions > speak > so loud, I can't hear a word you're saying." > > -Greg Graffin (Bad Religion) > -- "Hey brother christian with your high and mighty errand, Your actions speak so loud, I can't hear a word you're saying." -Greg Graffin (Bad Religion) ------=_Part_89893_1325410.1183475524836--