Filter from date - Ecto/Elixir

I’m making a method to filter by the current date, but it’s not working

defp date(d) do
d = ~D[2021-09-23]
from s in SchemaOp, where: fragment("?::date", s.inserted_at) >= ^d
end

is giving this error

variable "s" does not exist and is being expanded to "s()", please use parentheses to remove the ambiguity or change the variable nameElixir

variable "s" does not exist and is being expanded to "s()", please use parentheses to remove the ambiguity or change the variable nameElixir

(CompileError) cannot use ^date outside of match clauses

Make sure import Ecto.Query statement is present

2 Likes