# Filtering dates

**URL:** <https://www.ruby-forum.com/t/filtering-dates/115506>\
**Category:** Rails\
**Created:** [September 25, 2007, 9:20pm UTC](https://www.ruby-forum.com/t/filtering-dates/115506 "2007-09-25T21:20:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [September 25, 2007, 9:20pm UTC](https://www.ruby-forum.com/t/filtering-dates/115506/1 "2007-09-25T21:20:21Z")

</div>

Hi,

I’m having some records with a start- and end-date:

1. start= 01/03/2007 end 05/05/2007
2. start= 01/04/2007 end 20/06/2007
3. start= 15/07/2007 end 01/08/2007

How can I query the records that lie in a specific month?

I need for example all records that occur in the month may (05).

So if a record starts on 01/03/2007 and ends on 05/05/2007 =\> it lies in  
the month may

But the 2nd record also lies in the month may! It starts on 01/04/07 and  
ends on 20/06/07

The third record doesn’t occur in the month may

Any help would be welcome :). It looks simple, but it’s driving me nuts

Thanks

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [September 25, 2007, 9:29pm UTC](https://www.ruby-forum.com/t/filtering-dates/115506/2 "2007-09-25T21:29:47Z")

</div>

Maarten P. wrote:

> I need for example all records that occur in the month may (05).
> 
> Thanks

something like: start\_date \<= end\_of\_may and end\_date \>= start\_of\_may?  
sorry for the lack of code - it’s 3:30AM and my brain’s left for the  
night!

Cheers,  
Mohit.  
9/26/2007 | 3:28 AM.

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [September 25, 2007, 9:55pm UTC](https://www.ruby-forum.com/t/filtering-dates/115506/3 "2007-09-25T21:55:15Z")

</div>

jezus … I feel stupid 🙂 Works great… Thanks a lot!

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [September 26, 2007, 4:39pm UTC](https://www.ruby-forum.com/t/filtering-dates/115506/4 "2007-09-26T16:39:19Z")

</div>

Maarten P. wrote:

> jezus … I feel stupid 🙂 Works great… Thanks a lot!

Glad to help.

Cheers,  
Mohit.  
9/26/2007 | 10:38 PM.
