开发者

a question on ActiveRecord query

in my model, I use the where statement to query the DB table:

where(:date=>start_date..end_date)

It is obvious that I would like to get all records between start_date and end_date in th开发者_JAVA百科e date column. The start_date and end_date are Date type values.

Based on this query, I get the results from the table BUT not exactly everything.

The data match the date value of "end_date" is not return. That's this query exclude the data on end_date, it only get the results from start_date to end_date-1.day, how to get rid of this? I want to use this query to return the data with end_date>=date>=start_date


Try: where('date BETWEEN ? AND ?', start_date, end_date)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜