From: sto.mar@... Date: 2013-02-23T05:31:53+09:00 Subject: Re: Difference of 2 dates interms of years. Am 22.02.2013 20:43, schrieb Xavier R.: > Matt Mongeau wrote in post #1098484: >> Post some things you've tried. > > > I tried the below : > > def calculate_difference > minutes = (Date.parse("2009-06-20") - Date.today).to_i / 60 > days = minutes / (24*60) > minutes -= days * 24*60 > hours = minutes / 60 > minutes -= hours * 60 > "#{days}d#{hours}h#{minutes}m" > end > > which is not the one - I am looking for. :) Use irb to find out what each expression actually returns. Consider this: (Date.parse("2009-06-20") - Date.parse("2009-06-18")).to_i => 2 --