Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I compare dates in queries with datetimetz? #76

Open
eteubert opened this issue Feb 20, 2018 · 0 comments
Open

How do I compare dates in queries with datetimetz? #76

eteubert opened this issue Feb 20, 2018 · 0 comments

Comments

@eteubert
Copy link

With Ecto-Date fields I can do query comparisons like this:

from(e in query, where: fragment("? > NOW() - interval '24 hours'", e.some_date))

However that does not work.

operator does not exist: datetimetz > timestamp with time zone

I tried using Timex to generate the value to compare, but that did not work either:

from(e in query, where: e.some_date > ^one_day_ago())

defp one_day_ago do
  Timex.now()
  |> Timex.shift(hours: -24)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant