繁体   English   中英

Ruby Rails-按日期月份查询

[英]Ruby Rails - Query by Date Month

我要在“游戏”表中选择所有条目,其中“日期”列具有一个月份大于6的条目。“游戏”表的列为date_column,id,winning_side,status,away_score,home_score。 该数据库是Postgres。 就像是

Game.where("date_part(month, date_column) > ?", 6)

date_part似乎是正确的SQL函数,但这失败了。

对“ month”参数使用引号:

Game.where("date_part('month', date_column) > ?", 6)

您需要用单引号括住单词month,即

Game.where("date_part('month', date_column) > ?", 6)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM