title: I want to use query in rails just like:
body: <p>I face a problem during selection with order. It is not working. Query:</p>
  
  <pre><code>Order.select("order_at BETWEEN ? AND ?","#{Time.now}","#{Time.now - 20.day}")
  </code></pre>
  
  <p>The issue I am facing is I have some other stuff with this as well. </p>
  
  <pre><code>Order.joins('left joing with some association').group('orders.id').select("SUM(CASE WHEN association.created_at BETWEEN '#{Time.now.utc}' AND '#{(Time.now - 20days).utc}' THEN association.quantity ELSE 0 END) as total_qty")
  </code></pre>
  
  <p>Now I want this <code>Time.now.utc</code> to be pass in as external parameter like this</p>
  
  <p>Order.select("order_at BETWEEN ? AND ?","#{Time.now}","#{Time.now - 20.day}")</p>
  
  <p>Any help is appriciated.</p>