I'm trying to create a function and specify a date format but the date format is being taken as a column name because somehow inside format it's not being able to be represented as a string. I have tried %s, quote indent and everything else but doesnt work. Below is my code and the error I'm getting
drop function if exists foo(_t text);
create or replace function foo(_t text)
returns TABLE(Stage_ID bigint,Date varchar) as
$func$
begin
return query
execute format('Select Stage_ID,Date
from table
where to_date(Date, "YYYY-MM-DD")==%I',_t);
end
$func$ language plpgsql;
select * from foo('2010-01-01');
ERROR
ERROR: column "YYYY-MM-DD" does not exist
LINE: where TO_DATE(Date, "YYYY-MM-DD") = p...