我有一個是出口一些列的觀點,一列被稱爲比較日期從數據庫
'created_at' type:"timestamp without timezone" format: "2014-03-20 12:46:36.590253"
在軌我有一個方法,它是從視圖中獲取數據,並試圖篩選數據由一個日期。我試圖將created_at敲入date(),但仍然無法正常工作。 有什麼建議嗎?
return ActiveRecord::Base.connection.select_all(" select * from db_functions where date(created_at) >= #{date_p} AND date(created_at) <= #{date_p}")
PG::UndefinedFunction: ERROR: operator does not exist: date >= integer
LINE 2: ...select * from db_functions where date(created_at) >= 2014-03...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.