From: Ryan Davis Date: 2012-10-06T06:30:35+09:00 Subject: Re: Ruby range - verify if date lies between two specified dates On Oct 5, 2012, at 14:01 , ideal one wrote: > Hi All, > I came across some issue in verifying if a date lies between two > specified dates. > > now = Date.today > today = now.strftime('%d-%b-%Y') > last_Seven_Days = (now - 7).strftime('%d-%b-%Y') > > ... > > I dunno whether I am properly comparing dates or Strings..!! > any better way and stable way to do this. You're comparing strings and you don't want to do that: >> '01-Oct-2012'.succ => "01-Oct-2013" vs: >> [Date.today.to_s, Date.today.succ.to_s] => ["2012-10-05", "2012-10-06"] (ignore the fact that I used #to_s here... it's just to make the output readable)