benonymus

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

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

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.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement