Connecting Tech Pros Worldwide Forums | Help | Site Map

Displaying Records between 2 dates

Newbie
 
Join Date: Apr 2009
Posts: 1
#1: Apr 7 '09
How to display the records between 2 dates in ruby on rails
I have 2 text boxes where i fill the 2 dates and want to display the records between these 2 dates from the database tables

Thanks in advance,
vaibhavi,,,

Expert
 
Join Date: May 2007
Posts: 213
#2: Apr 7 '09

re: Displaying Records between 2 dates


You can use :conditions
Expand|Select|Wrap|Line Numbers
  1. data = ModelName.find(:all, :conditions => "date >= 'yyyy-mm-dd' and date <= 'yyyy-mm-dd'")
or you can write the SQL query, then use ModelName.find_by_sql(query).
Reply