我有一个正在导出一些列的视图,其中一列称为
'created_at' type:"timestamp without timezone" format: "2014-03-20 12:46:36.590253"
在 Rails 中,我有一个方法,它从视图中获取数据并尝试按日期过滤数据。我尝试将 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.