From: | Eric Walstad <eric(at)ericwalstad(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | formatting a date when some nulls exist |
Date: | 2002-09-02 22:49:54 |
Message-ID: | 3D73EB12.4090501@ericwalstad.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi All,
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
I'm assuming that the error is because of the null values. If I
constrain the query to a record which I know has a valid date, it
returns the formatted date as I would expect:
ewtest=# select to_char(birthday, 'YYYY-MM-DD') from contacts where
fn='Rhys';
to_char
------------
1943-10-18
(1 row)
I suspect that I need to COALESCE or CASE my way out of this, but I
haven't been able to figure out how. I'm hoping someone out there can
tell me how to return the formatted date or null or an empty string.
Thanks for any help!
Eric.
From | Date | Subject | |
---|---|---|---|
Next Message | Eric Walstad | 2002-09-02 23:02:38 | formatting a date when some nulls exist |
Previous Message | George Donnahoo | 2002-09-02 21:34:38 | RAISE statements |