Correct syntax

Started by Sterpu Victoralmost 12 years ago2 messagesgeneral
Jump to latest
#1Sterpu Victor
victor@caido.ro

How would I write sutch a query?
SELECT to_timestamp ('10-10-2013 15:00', 'DD-MM-YYYY HH24:MI') +
interval REPLACE('1.30', '.', ':')||' hours'
This gives error at REPLACE.
Thank you.

#2Vik Fearing
vik@postgresfriends.org
In reply to: Sterpu Victor (#1)
Re: Correct syntax

On 04/11/2014 10:58 AM, Victor Sterpu wrote:

How would I write sutch a query?
SELECT to_timestamp ('10-10-2013 15:00', 'DD-MM-YYYY HH24:MI') +
interval REPLACE('1.30', '.', ':')||' hours'
This gives error at REPLACE.
Thank you.

The way you have interval, it expects a constant. You need to cast your
expression like this:

SELECT to_timestamp ('10-10-2013 15:00', 'DD-MM-YYYY HH24:MI') +
(REPLACE('1.30', '.', ':')||' hours')::interval

--
Vik