Here I have month and year as params...these two are change based on select box value....
Here i need to find records with in month choosen from select box....
Rails Query:
year=params[:month_name].split(",")[0].to_i
month=params[:month_name].split(",")[1].to_i
date=DateTime.new(year,month)
@all_events=Events::Event.where(:created_at => date.beginning_of_month..date.end_of_month)
From console:(Better understanding)
2.1.1 :005 > date=DateTime.new(2013,02)
=> Fri, 01 Feb 2013 00:00:00 +0000
2.1.1 :006 > date.beginning_of_month..date.end_of_month
=> Fri, 01 Feb 2013 00:00:00 +0000..Thu, 28 Feb 2013 23:59:59 +0000
Here i need to find records with in month choosen from select box....
Rails Query:
year=params[:month_name].split(",")[0].to_i
month=params[:month_name].split(",")[1].to_i
date=DateTime.new(year,month)
@all_events=Events::Event.where(:created_at => date.beginning_of_month..date.end_of_month)
From console:(Better understanding)
2.1.1 :005 > date=DateTime.new(2013,02)
=> Fri, 01 Feb 2013 00:00:00 +0000
2.1.1 :006 > date.beginning_of_month..date.end_of_month
=> Fri, 01 Feb 2013 00:00:00 +0000..Thu, 28 Feb 2013 23:59:59 +0000
No comments:
Post a Comment