When I create a query using ecto in Elixir, I am not sure how to compare the time in the "where" section.
In the schematic part, I declare create_at as :datetime
schema "tenant" do field :id, :integer field :created_at, :datetime
and the request part is similar to
def sample_query do query = from t in Tenant, where: t.id == 123, where: t.created_at == %Ecto.DateTime{{2015, 4, 27}, {10, 8, 42}}, select: t end
It seems that
where: t.created_at <= %Ecto.DateTime{{2015, 4, 27}, {10, 8, 42, 0}},
part of an irregular shape. Can someone tell me how to do it right?
PS: on how to define the create_at field, the link below gave me an answer
Default datetime with Ecto and Elixir
source share