Re: Correct syntax - Mailing list pgsql-general

From Vik Fearing
Subject Re: Correct syntax
Date
Msg-id 5347B2A1.2030205@dalibo.com
Whole thread Raw
In response to Correct syntax  ("Victor Sterpu" <victor@caido.ro>)
List pgsql-general
On 04/11/2014 10:58 AM, Victor Sterpu wrote:
blockquote.cite { margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc } blockquote.cite2 {margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc; margin-top: 3px; padding-top: 0px; } .plain pre, .plain tt { font-family: monospace; font-size: 100%; font-weight: normal; font-style: normal; } body {font-family: Tahoma;font-size: 12pt;} .plain pre, .plain tt {font-family: Tahoma;font-size: 12pt;}
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

pgsql-general by date:

Previous
From: "Victor Sterpu"
Date:
Subject: Correct syntax
Next
From: Alban Hertroys
Date:
Subject: Re: Linux vs FreeBSD