Rails date comparison; date greater or equal to days ago

Viewed 18797

A date in my database looks like this: 2012-07-23

I am trying to see if the date is older than 7 days ago and less than 14 days ago or see if the date is greater than 14 days ago, but am having no luck..

Here is my code:

def progress_report_status_check(date)
    progress_date = date.to_date
    seven_days = 7.days.ago.to_date
    fourteen_days = 14.days.ago.to_date

    if seven_days > (progress_date - 7.days.ago.to_date) or (progress_date - 14.days.ago.to_date) < fourteen_days
      "due"
    elsif (progress_date - 14.days.ago.to_date) > fourteen_days 
      "overdue"
    end 
  end
2 Answers
Related