benonymus
DateTime comparison in query
Hey there,
I have this code:
from(
ge in query,
join: e in assoc(ge, :event),
where: e.start_date <= ^date
)
As we know this can cause problems because of the date/datetime comparisons as it is described here for example : Date — Elixir v1.20.2
my questions is then how could I use DateTime.compare/2 with e.start_date here as the first argument?
Marked As Solved
NobbZ
As far as I remember, ecto does translate this into proper comparison on the SQL level, and the DateDtime struct isn’t actually involved in the comparison.
Last Post!
NobbZ
The linked article is 4 years old and probably refers to a version of elixir that is not only deprecated but literally dead.
At the time the article got released, ecto 1.0.7 was current. Today we are at 3.2.2.
The Ecto.DateTime module has been deprecated in 2.2.4.
So I won’t say that article is pointless, I’d just say its not applicable anymore today, but it might have had its worth back the day it has been published.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










