views:

1349

answers:

1

Hello

I am trying to get the difference in hours for two different Time instances. I get these values from the DB as a :datetime column

How can I do this so that it includes the months and years as well in the calculation while ignoring or rounding the minutes? Can this only be done manually or is there a function to do this?

Thank you

+4  A: 
((date_2 - date_1) / 3600).round

or

((date_2 - date_1) / 1.hour).round
Romulo A. Ceccon