Eric Walstad <eric@walstads.net> writes:
> I'm trying to format a date type column, which contains some nulls. I'm
> getting an error:
> ewtest=# select to_char(birthday, 'YYYY-MM-DD') from contacts;
> ERROR: Unable to convert date to tm
How old is your Postgres?? AFAIR that misbehavior has been gone since
6.5 or so. Certainly any recent version works:
regression=# create table foo (f1 date);
CREATE TABLE
regression=# insert into foo values('today');
INSERT 288761 1
regression=# insert into foo values(null);
INSERT 288762 1
regression=# select to_char(f1, 'YYYY-MM-DD') from foo;
to_char
------------
2002-09-02
(2 rows)
regression=#
regards, tom lane