Question: I need to write a query that finds all documents created on a specified date.

Let's suppose that the date is today.

I tried this:

```
Document.all(:created_at => Date.parse(Time.now.strftime('%Y/%m/%d')))

```

but I got:

> 
> Cannot serialize an object of class Date into BSON.
> 
> 
> 

Thanks for your help.

**UPDATE**
This link explains how to do so [Date Range Queries With MongoMapper](https://web.archive.org/web/20130309080838/kplawver.posterous.com/date-range-queries-with-mongomapper).

```
Document.count( :created_at => { '$gt' => 2.days.ago.midnight, '$lt' => 1.day.ago.midnight } )

```

Answer: 
**UPDATE:** This link explains how to do so [Date Range Queries With MongoMapper](http://kplawver.posterous.com/date-range-queries-with-mongomapper).

```
Document.count( :created_at => { '$gt' => 2.days.ago.midnight, '$lt' => 1.day.ago.midnight } )

```
Use the technique @mu-is-to-short pointed out to create the date.

But the format of the where statement can be simpler:

```
date = Time.new(2021,1,24, 0,0,0).utc
docs = Document.where(:updated_at.gte => date).all

```