Re: Mailing

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Mailing
Дата
Msg-id 20041005075036.E25039@megazone.bigpanda.com
обсуждение исходный текст
Ответ на Mailing  (Todd P Marek <affe23@somahq.com>)
Список pgsql-general
On Tue, 5 Oct 2004, Todd P Marek wrote:

> Hello-
>
> I am in the process of translating a site using mysql as the backend
> over to postgres.  I have a lot of time data that I would like to
> display to the user in the form of a schedule.
>
> I am using the to_char function to make the times human friendly
>
>     to_char(class_schedule.endtime, 'HH:MI:SS AM')
>
> which returns
>
>     06:30:00 AM - 07:30:00 AM
>
> I am really looking to get it outputting like this.
>
>     6:30 AM - 7:30 AM

For the seconds, do you want seconds if it's not 00, or do you just not
want seconds at all? Because removing :SS will get rid of the seconds
display.

For the leading 0s, you'd probably need to do a user defined function to
trim them off, but it'd probably be relatively simple use of ltrim, so you
might do something like:

create function format_time(time) returns text as '
 select ltrim(to_char($1, ''HH:MI AM''), ''0'')' language 'sql';

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Mailing
Следующее
От: Robby Russell
Дата:
Сообщение: Re: Mailing