Re: Alternative to AS?

From: Christian Ramseyer <rc(at)networkz(dot)ch>
To: Helgi Örn <sacredeagle(at)gmail(dot)com>
Cc: PostgreSQL - newbie <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Alternative to AS?
Date: 2010-10-06 11:40:46
Message-ID: 4CAC603E.9000809@networkz.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Helgi Örn 2010-10-06 18:36:46 Re: Alternative to AS?
Previous Message Helgi Örn 2010-10-06 09:30:08 Re: Alternative to AS?