I want to search for all declarations in a certain month number. “declaration_date” is a datetime attribute. I have this, but it fails, any ideas?
declaration = Declarations.all(:conditions => ['declaration_date.strftime("%-m") = 2')
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you want declarations within a month in a specific year? If so, try something like this:
You can follow this technique to get declarations in the same month over several years.
See also, section 11.3 of the Active Record Query Interface docs http://guides.rubyonrails.org/active_record_querying.html