On Oct 5, 2012, at 14:01 , ideal one <lists / ruby-forum.com> wrote:

> Hi All,
>    I came across some issue in verifying if a date lies between two
> specified dates.
>=20
> now =3D Date.today
> today =3D now.strftime('%d-%b-%Y')
> last_Seven_Days =3D (now - 7).strftime('%d-%b-%Y')
>=20
> ...
>=20
> 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
=3D> "01-Oct-2013"

vs:

>> [Date.today.to_s, Date.today.succ.to_s]
=3D> ["2012-10-05", "2012-10-06"]

(ignore the fact that I used #to_s here... it's just to make the output =
readable)