这是我尝试过的。
date = Ecto.DateTime.from_erl(:calendar.universal_time())
query |> where([record], record.deadline >= ^date)
我也尝试过
date = Ecto.DateTime.from_erl(:calendar.universal_time())
query = from m in MyApp.SomeModel,
where: m.deadline >= ^date,
select: m
两者返回相同的消息
value `%Ecto.DateTime{..}` in `where` cannot be cast to type :datetime in query
据我了解,我应该在查询中使用 Ecto.DateTime 。也许我错过了一些明显的东西?谢谢!
The :datetime
type 是本机类型,仅适用于元组。如果您将列类型设置为Ecto.DateTime
在您的架构中,它将能够使用更高级别的类型,例如 Ecto.DateTime 结构。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)