title: Find Records with Datetime that match today's date - Ruby on Rails
body: <p>I have a table of deals and need to find records where the date matches today's date.</p>
  
  <p>From the rails console, the date field I need to match looks like this. I've assigned a record to deal for testing.</p>
  
  <pre><code>ruby-1.9.2-p0 &gt; deal.start
  =&gt; Tue, 10 May 2011 00:00:00 UTC +00:00 
  </code></pre>
  
  <p>If I try to find any records matching the start date with today like this I get nil</p>
  
  <pre><code>ruby-1.9.2-p0 &gt; Deal.find_by_start(Date.today)
  =&gt; nil
  </code></pre>
  
  <p>then I thought I could match by converting Date.today to a datetime.</p>
  
  <pre><code>ruby-1.9.2-p0 &gt; Date.today.to_datetime
  =&gt; Tue, 10 May 2011 00:00:00 +0000 
  ruby-1.9.2-p0 &gt; Deal.find_by_start(Date.today.to_datetime)
  =&gt; nil
  </code></pre>
  
  <p>How can I get this to work? I'm using Rails 3.</p>
  
  <p>Edit:
  I thought about converting them both to a consistent format which will works but not when trying to using the find_by_start method</p>
  
  <pre><code>ruby-1.9.2-p0 &gt; deal.start.strftime("%a, %e %B %Y") == Date.today.strftime("%a, %e %B %Y")
  =&gt; true 
  
  ruby-1.9.2-p0 &gt; Deal.find_by_start.strftime("%a, %e %B %Y") == Date.today.strftime("%a, %e %B %Y")
  NoMethodError: undefined method `strftime' for nil:NilClass
  </code></pre>