Re: Correct syntax

From: Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>
To: Victor Sterpu <victor(at)caido(dot)ro>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Correct syntax
Date: 2014-04-11 09:15:13
Message-ID: 5347B2A1.2030205@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2014-04-11 10:05:49 Re: Linux vs FreeBSD
Previous Message Victor Sterpu 2014-04-11 08:58:53 Correct syntax