Re: formatting a date when some nulls exist

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: formatting a date when some nulls exist
Дата
Msg-id 28751.1031011720@sss.pgh.pa.us
обсуждение исходный текст
Ответ на formatting a date when some nulls exist  (Eric Walstad <eric@walstads.net>)
Список pgsql-novice
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

В списке pgsql-novice по дате отправления:

Предыдущее
От: Eric Walstad
Дата:
Сообщение: formatting a date when some nulls exist
Следующее
От: Mark Fletcher
Дата:
Сообщение: Dealing with unique IP adresses and ranges