Is there any magic sequence of quotes or backslashes that will get the following (simplified version) to do the obvious thing?
CREATE FUNCTION doesnt_work(integer) RETURNS date LANGUAGE SQL AS
'SELECT (date ''epoch'' + interval '' $1 day'')::date ' STRICT IMMUTABLE;
No variable interpolation is performed; the interval 1 day is always used.