I have to query the date range on the basis of timestamps in the model. what i have tried so far is
str="2017-12-18"
{:ok, ed}=Ecto.Date.cast(str)
ed= ed |> Ecto.Date.from_erl |> NaiveDate.from_erl!
Repo.all(from l in Log, where: l.inserted_at == ^ed)
However the date in the postgres is in the form of datetime, e.g. 2017-12-18 19:58:01.414.
but i just want to query on the date and not the time. However if i use Ecto.DateTime and NaiveDateTime and pass the acurate datetime in string, it works. but i just want to match on the date, instead. How can that be possible?
Thanks
ed |> Ecto.Date.from_erl |> NaiveDate.from_erl!can not be a real code, please correct the question. - Aleksei Matiushkin