开发者

a question on ActiveRecord query

开发者 https://www.devze.com 2023-02-06 08:53 出处:网络
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开发者_JA

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

精彩评论

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