[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

postgres date formatting?



I know this isn't the postgres user group, but if anyone has any
insight, I'd sure appreciate it.

Summary: attempting to use to_date on a table value results in a
to_timestamp error.  What am I doing wrong?

I have a little database and want to prettyprint some dates on the web
interface.

In /etc/postgres/postgres.conf , I have the following set:
DATESTYLE = 'iso,european'

This is confirmed within psql:

ski=> show datestyle;
           DateStyle
-------------------------------
 ISO with European conventions
(1 row)

I have a table with a column of type 'date'.

ski=> select starting from visits;
  starting
------------
 2003-12-14
etc ...

Here's what to_date gets me:

ski=> select to_date (starting, 'DD Mon YYYY') from visits ;
ERROR:  to_timestamp(): bad value for MON/Mon/mon

Just for grins, I thought I'd try changing the datestyle:

ski=> set session datestyle = 'postgres,us';
SET
ski=> select starting from visits;
  starting
------------
 12-14-2003
etc ...

But no matter what datestyle I use, I get that to_timestamp() error when
trying to prettyprint my table.

For the record, I can use to_date in the canonical example just fine:

ski=> select to_date('05 Dec 2000', 'DD Mon YYYY');
  to_date
------------
 2000-12-05
(1 row)

-- 
monique



Reply to: