hi,
Is there an easy way of calculating the difference in months between two
dates in a controller.
thanks
hi,
Is there an easy way of calculating the difference in months between two
dates in a controller.
thanks
ben wrote:
hi,
Is there an easy way of calculating the difference in months between two
dates in a controller.thanks
well this is how I have done it, just out of interest, im going to need
to build a few more date functions like this, how would I go about
creating a plugin to include this?
pLoopDate = Date.new(2005,10,1)
pLoopDateMax = Date.new(2006, 10, 1)
while pLoopDate <= pLoopDateMax
pNumberOfMonths = pNumberOfMonths + 1
if pLoopDate.month == 12
pLoopDate = Date.new((pLoopDate.year+1),1,1)
else
pLoopDate =
Date.new(pLoopDate.year,(pLoopDate.month+1),1)
end
end
On 7/7/06, ben [email protected] wrote:
hi,
Is there an easy way of calculating the difference in months between two
dates in a controller.
You could do (date2.year12+date2.month) - (date1.year12+date1.month).
/ CJ
Use the date helper for this date diff issues,
ActionView::Helpers::DateHelper
Check out distance_of_time_in_words
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