convert column of integer type to time type?

From: Carol Cheung <cacheung(at)consumercontact(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: convert column of integer type to time type?
Date: 2007-06-27 15:36:50
Message-ID: 46828412.8040203@consumercontact.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I want to convert a column of type integer to type 'time without time zone'.

If I have a table with an integer column

some_int
----------
12
345
1622
1

Then, I add a column to the table of type 'time without time zone'
(some_time).
and, I can perform the update:

UPDATE tester SET some_time = CAST (to_char(some_int, 'FM99909:99') AS
time without time zone);

some_int | some_time
----------+-----------
12 | 00:12:00
345 | 03:45:00
1622 | 16:22:00
1 | 00:01:00

My question is: Is it possible to alter the 'some_int' column directly
without having to create a temporary 'some_time' holding column?

Thanks in advance,
C

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Glaesemann 2007-06-27 16:22:45 Re: convert column of integer type to time type?
Previous Message Andrej Ricnik-Bay 2007-06-26 19:52:33 Re: yet another simple SQL question