title: Rails `where` for time less than queries
body: <h1>Setup</h1>
  
  <p>Rails' <code>where</code> method can take a range in a hash to generate a query that will search for a value that is within the range. For example:</p>
  
  <pre><code>User.where(cash_money: 10..1000)
  #=&gt; SELECT `users`.* FROM `users`  WHERE (`users`.`cash_money` BETWEEN 10 AND 1000)
  </code></pre>
  
  <p>This can also be used with timestamps like</p>
  
  <pre><code>User.where(last_deposit: 10.days.ago..1000.days.ago)
  #=&gt; SELECT `users`.* FROM `users`  WHERE (`users`.`last_deposit` BETWEEN '2014-05-19 14:42:36' AND '2011-09-02 14:42:36')
  </code></pre>
  
  <p>I've found that you can do a simple less than or greater than with numbers using the hash syntax like this</p>
  
  <pre><code>User.where(cash_money: 10..Float::INFINITY)
  #=&gt; SELECT `users`.* FROM `users`  WHERE (`users`.`cash_money` &gt;= 10)
  </code></pre>
  
  <p>and the same can be done with <code>-Float::INFINITY</code> for less than queries.</p>
  
  <h1>Question</h1>
  
  <p>Is there a way to do this with timestamps so I can get a query like the following?</p>
  
  <pre><code>SELECT `users`.* FROM `users`  WHERE (`users`.`last_deposit` &gt;= '2014-05-19 14:42:36')
  </code></pre>
  
  <p>I cannot use <code>Float::INFINITY</code> or <code>Date::Infinity</code> with a range as they both error with <code>ArgumentError: bad value for range</code>.</p>
  
  <h1>Current Simple Solution</h1>
  
  <pre><code>User.where('`users`.`last_deposit` &gt;= ?', 10.days.ago)
  </code></pre>
  
  <p>will generate the same SQL but if this can be done with objects other than strings, I'd like to do so.</p>
  
  <h1>Potential (Meh) Answer</h1>
  
  <p>This is kind of lousy but it could be done with ranges using <code>Time.at(0)</code> and <code>Time.at(Float::MAX)</code>. I have a feeling these could result in equally lousy SQL queries though.</p>