Re: Alternative to AS?

Поиск
Список
Период
Сортировка
От Christian Ramseyer
Тема Re: Alternative to AS?
Дата
Msg-id 4CAC603E.9000809@networkz.ch
обсуждение исходный текст
Ответ на Re: Alternative to AS?  (Helgi Örn <sacredeagle@gmail.com>)
Список pgsql-novice
>>>
>>> I have this form mysql:
>>> SELECT tid_in, TIME_FORMAT(tid_in, '%H.%i')AS format FROM timmar;

I think you want something like:

PG=# select '23:59' as timestring, '23:59'::time as format ;
 timestring |  format
------------+----------
 23:59      | 23:59:00
(1 row)

Or as you seem to have "." as separator (tough it depends probably on
the locale if 23.59 is a time or not)

PG=# select '23.59' as timestring, replace('23.59', '.',':')::time as
format;
 timestring |  format
------------+----------
 23.59      | 23:59:00

Adapted to your example:
SELECT tid_in, replace(tid_in, '.', ':')::time as format FROM timmar;

All in all, "as" should work as you think, it's more the time conversion
/ from-string-parsing that's different.

Christian




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

Предыдущее
От: Helgi Örn
Дата:
Сообщение: Re: Alternative to AS?
Следующее
От: Helgi Örn
Дата:
Сообщение: Re: Alternative to AS?