Re: Question on interval
От | Michael Glaesemann |
---|---|
Тема | Re: Question on interval |
Дата | |
Msg-id | 4AA02EED-0C35-4604-8881-3D3B26C351A9@seespotcode.net обсуждение исходный текст |
Ответ на | Question on interval (Wei Weng <wweng@kencast.com>) |
Список | pgsql-sql |
On Apr 20, 2007, at 13:53 , Wei Weng wrote: > How do I write a query that converts an interger to the interval type? > > Like convert integer 10 to INTERVAL '10 seconds'? An easy way to do this is: SELECT 10 * INTERVAL '1 second'; > > The integer is a column in a table though, so it is more like > convert integer tbl.theInteger to INTERVAL 'tbl.theInteger seconds". If you'd like to change the type of the column to interval, you can use something like ALTER TABLE a_table ALTER COLUMN an_integer_column TYPE INTERVAL USING an_integer_column * INTERVAL '1 second'; You could also create a view that would present the integer column as an interval if you don't want to alter the table itself. Does this help? Michael Glaesemann grzm seespotcode net
В списке pgsql-sql по дате отправления: