From: ideal one Date: 2012-10-06T09:16:03+09:00 Subject: Re: Ruby range - verify if date lies between two specified dates Todd B. wrote in post #1078765: > On Fri, Oct 5, 2012 at 4:01 PM, ideal one wrote: >> >> range === last_date => sometimes comes as TRUE sometimes as FALSE >> >> I dunno whether I am properly comparing dates or Strings..!! >> any better way and stable way to do this. >> >> -- >> Posted via http://www.ruby-forum.com/. >> > > first_date = Date.new(2012, 10, 1) > last_date = Date.new(2012, 10, 31) > range = (first_date..last_date) > range.include?(Date.new(2012, 10, 5)) > => true > range.include?(Date.new(2012, 11, 1)) > => false > > Todd Hi Guys, I tried doing this, can anyone point out why it is not working irb(main):003:0> today = Date.today => # irb(main):004:0> seven = (today - 7) => # irb(main):005:0> range = (today..seven) => #..# irb(main):006:0> first_element = '04-OCT-2012 06:29:05' => "04-OCT-2012 06:29:05" irb(main):007:0> top_date = Date.parse first_element => # irb(main):008:0> range.include? top_date => false I was Expecting a TRUE here, cos '2012-10-04' falls between the range mentioned!! -- Posted via http://www.ruby-forum.com/.