Monday, April 27, 2009

Gets Days from the difference between two dates.

Example:
> a = "2009-04-01 18:33:05"
> b = Time.now
> c = b.to_date - a.to_date
O/P: Rational(4, 1)
> c.to_i
=> 4
OR
> c = (b.to_date - a.to_date).to_i
=> 4

No comments:

Post a Comment