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

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
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

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 131117 1222
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement