Auto-formatting timestamps?

Поиск
Список
Период
Сортировка
От Peter Koczan
Тема Auto-formatting timestamps?
Дата
Msg-id 4544e0330805130858q6755e1b1h8376b5839fa87a5a@mail.gmail.com
обсуждение исходный текст
Ответы Re: Auto-formatting timestamps?
Список pgsql-sql
Hi all,

I'm undergoing a port from an old Sybase database to Postgres. It's
going surprisingly well, but I have a question regarding formatting of
timestamps.

In Sybase, we get:
:> select date from checkoutdate;
date
'May  1 2001 12:00AM'
...

In Postgres:
=> select date from checkoutdate;      date
---------------------2001-05-01 00:00:00
...

I can properly format it using to_char:
=> select to_char(date, 'Mon DD YYYY HH:MIAM') as date from checkoutdate;      date
---------------------May 01 2001 12:00AM
...

Short of creating a wrapper type for timestamp (which seems like
overkill just for modifying the output function), is there a way to
output the Sybase format automatically (i.e. without a call to
to_char)?

I've found some code that actually somewhat depends on this format,
and one of my goals in this port is to change as little client code as
possible. Is it possible to automatically change the output like this,
preferably on a per-connection basis? I found stuff regarding the
datestyle parameter in the docs, but that doesn't quite do what I'd
like.

Thanks much,
Peter


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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: merge timestamps to intervals
Следующее
От: "Mag Gam"
Дата:
Сообщение: Re: Auto-formatting timestamps?