HI Folks, How to find current month? and How to collect current month data from our database? Please advice. Thank You.
on 2013-01-24 13:25
on 2013-01-24 13:33
On Thu, Jan 24, 2013 at 6:24 AM, Maddy <firstname.lastname@example.org> 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.  pry(main)> Time.new.strftime("%B") #=> "January"  pry(main)> Time.new.strftime("%b") #=> "Jan"  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.