Here is what I have tried.
date = Ecto.DateTime.from_erl(:calendar.universal_time())
query |> where([record], record.deadline >= ^date)
I also tried
date = Ecto.DateTime.from_erl(:calendar.universal_time())
query = from m in MyApp.SomeModel,
where: m.deadline >= ^date,
select: m
Both return same message
value `%Ecto.DateTime{..}` in `where` cannot be cast to type :datetime in query
From what I understand I am supposed to be using Ecto.DateTime in my queries. Maybe I am missing something obvious? Thanks!
The :datetime
type is a native type and works only with tuples. If you set your column type to Ecto.DateTime
in your schema, it will be able to work with higher level types like the Ecto.DateTime struct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With