Showing posts with label days. Show all posts
Showing posts with label days. Show all posts

Thursday, July 19, 2012

Get the Date difference in days

Hello guys,
        Wanna to get the date difference in terms of days?

eg.
date_x = Time.now.to_date
date_y = Date.parse('2012-05-20')

passed_days = (date_x.to_date - date_y.to_date).to_i

passed_days should give the date difference in days.

Tuesday, April 17, 2012

Number of days between two dates

Hello Rubies,
    Get the days between two dates using below method of ruby date class.

Lets consider we have date range like
date1 = Date.today.to_date
date2 = 1.year.ago.to_date
no_of_days = date1.mjd - date2.mjd

Hope this simple method of ruby date class will help you out to find days between to dates.