Trying to execute this postgres query:
select date('2015-10-05') from posts;
I'm passing the date as a string:
Ecto.Adapters.SQL.query!(
Repo, "select date('$1') from posts", ["2015-10-05"])
But getting an error that the datetime format is invalid.
** (Postgrex.Error) ERROR (invalid_datetime_format):
invalid input syntax for type date: "$1"
[debug] select date('$1') from posts ["2015-10-05"]
ERROR query=0.6ms
(ecto) lib/ecto/adapters/sql.ex:172: Ecto.Adapters.SQL.query!/5
However, I'm not passing it as a date, but as a string. Postgres' date() function accepts string too, AFAIK and the error is still the same when I add ::varchar to make sure it's a string. Any advice how can this be avoided?
psql? - Patrick Oscity2015-10-05is provided via arguments, I'm not sure how such query would look like. But otherwise it simply makes a query that selects the same date for all the posts - user2205259