DateTime comparison in query

Hey there,

I have this code:

      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 :

my questions is then how could I use with e.start_date here as the first argument?

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.


It seems like we have this phantom bug that a counter depending on this sometimes is not correct

@NobbZ - Are you suggesting you can use normal comparison operators in the query and that solutions such as this: are pointless?

@benonymus - I’m not even sure what you’re saying

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.