# limiting query with created\_at?

**URL:** <https://discuss.rubyonrails.org/t/limiting-query-with-created-at/9917>\
**Category:** rubyonrails-talk\
**Created:** [March 8, 2007, 11:14pm UTC](https://discuss.rubyonrails.org/t/limiting-query-with-created-at/9917 "2007-03-08T23:14:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philip\_Hallstrom1](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@Philip\_Hallstrom1](https://discuss.rubyonrails.org/u/Philip_Hallstrom1)\
**Post date:** [March 8, 2007, 11:14pm UTC](https://discuss.rubyonrails.org/t/limiting-query-with-created-at/9917/1 "2007-03-08T23:14:21Z")

</div>

> I have no idea why this isn't working but maybe a new set of eyes can help. I want to only collect posts from yesterday:
> 
> &nbsp;&nbsp;&nbsp;Post.find( :all, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:conditions =\> "posts.created\_at \> #{(1.day.ago).to\_i}", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:order =\> "posts.created\_at DESC", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:include =\> :person)

Let Rails convert the time into the format your database expects...

:conditions =\> ["posts.created\_at \> ?", 1.day.ago]

Otherwise you're going to need to format that time so your database understands it.
