"Thomas Leung" <thomasleung(at)hotmail(dot)com> writes:
> str := to_char($1, "YYYY");
> ERROR: Attribute "YYYY" not found
Double and single quotes are not interchangeable. Here you have written
an identifier, not a string literal. You'll need
str := to_char($1, ''YYYY'');
or
str := to_char($1, \'YYYY\');
according to taste.
regards, tom lane