Find Current Month?

HI Folks,

How to find current month?
and
How to collect current month data from our database?

Please advice.

Thank You.

On Thu, Jan 24, 2013 at 6:24 AM, Maddy [email protected]
wrote:

How to find current month?
and
How to collect current month data from our database?

I’m not trying to be a dick, but these are fundamental tasks that you
should have learned first.

[1] pry(main)> Time.new.strftime(“%B”) #=> “January”
[2] pry(main)> Time.new.strftime(“%b”) #=> “Jan”
[3] pry(main)> Time.new.month #=> 1

As for the latter, that’s a hard question to ask, because I would not
query by date the Rails way, I would opt to use PG functions to format
the date and query that way so without knowing a database I cannot
help there but it’s not hard to use where(“created_at >= ?”,
5.days.ago) though I don’t even know if that’s a good way to do it in
Rails because again I would never do date queries directly in Rails.