Re: Converting a timestamp to a time

Поиск
Список
Период
Сортировка
От Mark Morgan Lloyd
Тема Re: Converting a timestamp to a time
Дата
Msg-id 454DD92D.B18CAF62@telemetry.co.uk
обсуждение исходный текст
Ответ на Converting a timestamp to a time  (Mark Morgan Lloyd <markMLl.pgsql-general@telemetry.co.uk>)
Ответы Re: Converting a timestamp to a time  (Andreas Kretschmer <akretschmer@spamfence.net>)
Список pgsql-general
Andreas Kretschmer schrieb:
>
> Mark Morgan Lloyd <markMLl.pgsql-general@telemetry.co.uk> wrote:
> > What is the correct (or even any :-) way of converting a timestamp into a
> > time (without timezone etc.)?
>
> You can CAST it:
>
> test=# select now();
>               now
> -------------------------------
>  2006-11-05 11:16:05.205235+01
> (1 row)
>
> test=# select now()::time;
>       now
> ----------------
>  11:16:18.22527
> (1 row)

Thanks Andreas, I've ended up using CAST( ... AS TIME). I think the :: notation
might be fragile in this instance because of the machine-generated SQL which
gets a bit hairy in places.

I've also had to replace INTERVAL() with CAST( ... INTERVAL) wherever it occurs
and replace the result of a function with TIMESTAMP WITH TIME ZONE... hopefully
that won't mess anything up, the server is aggresively GMT since we have to deal
with several timezones simultaneously and it's the only way I could work it.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: max_fsm_pages
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Converting a timestamp to a time