Re: Alternative to AS? - Mailing list pgsql-novice

From Christian Ramseyer
Subject Re: Alternative to AS?
Date
Msg-id 4CAC603E.9000809@networkz.ch
Whole thread Raw
In response to Re: Alternative to AS?  (Helgi Örn <sacredeagle@gmail.com>)
List 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 by date:

Previous
From: Helgi Örn
Date:
Subject: Re: Alternative to AS?
Next
From: Helgi Örn
Date:
Subject: Re: Alternative to AS?