Re: formatting a date when some nulls exist

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: eric(at)walstads(dot)net
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: formatting a date when some nulls exist
Date: 2002-09-03 00:08:40
Message-ID: 28751.1031011720@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Eric Walstad <eric(at)walstads(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Mark Fletcher 2002-09-03 06:21:50 Dealing with unique IP adresses and ranges
Previous Message Eric Walstad 2002-09-02 23:02:38 formatting a date when some nulls exist