Re: Problem with extract(epoch from interval ...

From: Kaloyan Iliev <kaloyan(at)digsys(dot)bg>
To:
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with extract(epoch from interval ...
Date: 2013-01-23 11:23:22
Message-ID: 50FFC82A.3040305@digsys.bg
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thanks,
It works perfectly.

Regards,
Kaloyan Iliev
On 23.01.13 13:00, Ian Lawrence Barwick wrote:
> Hi
>
> 2013/1/23 Kaloyan Iliev <kaloyan(at)digsys(dot)bg>:
>> Hi,
>> I have a little problem with extract epoch from interval. It seems that the
>> query works if the interval is in a string but not from DB field.
>> Could someone provide support.
> (...)
>
> You have a casting error; instead of:
>
>> dbr=# SELECT extract(EPOCH FROM INTERVAL b) FROM a;
>> ERROR: syntax error at or near "b"
>> LINE 1: SELECT extract(EPOCH FROM INTERVAL b) FROM a;
> use
>
> SELECT extract(EPOCH FROM b::INTERVAL) FROM a;
>
> or
>
>
> SELECT extract(EPOCH FROM CAST (b AS INTERVAL)) FROM a;
>
>
> Regards
>
> Ian Barwick

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas 2013-01-23 12:11:55 Re: Re: [SQL] need some magic with generate_series()
Previous Message Ian Lawrence Barwick 2013-01-23 11:00:39 Re: Problem with extract(epoch from interval ...