Topic: More query troubles

Hey!

Is it possible to get the events, which have a 'date' column (yyyy-mm-dd), that happens this month? I've tried something like this:

:conditions => ['date.month = Time.now.month']

but that doesn't work...

Re: More query troubles

You can try something like this:

:conditions => ['my_date_column >= ? AND my_date_column <= ?', Time.now.beginning_of_month, Time.now.end_of_month]

Railscasts - Free Ruby on Rails Screencasts

Re: More query troubles

Wow Ryan, you're good!

Do you have a link to where I can read up on these date helpers?

Re: More query troubles

Rails offers many date/time helper methods for both Time and Integer objects. You can see the docs at those links. I really like the integer helper methods which allow you to do cool things like 3.days.ago

Railscasts - Free Ruby on Rails Screencasts