From: | Peter Nixon <listuser(at)peternixon(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: CAST INTERVAL to INT?? |
Date: | 2003-07-31 22:22:49 |
Message-ID: | bgc4qt$or4$1@main.gmane.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane wrote:
> Peter Nixon <listuser(at)peternixon(dot)net> writes:
>> I am trying to cast a INTERVAL to an INT (or BIGINT) without much
>> success.
>
> "extract(epoch from <interval>)" will produce the interval's value in
> seconds ... as a float8, but you can cast that to bigint ...
Thanks
The following seems to do what I need.
AcctSessionTime = (EXTRACT(EPOCH FROM(now()::timestamp with time zone -
AcctStartTime::timestamp with time zone -
'%{Acct-Delay-Time:-0}'::interval)))::BIGINT
If not, I am sure some users will start screaming shortly :-)
--
Peter Nixon
http://www.peternixon.net/
PGP Key: http://www.peternixon.net/public.asc
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Browne | 2003-07-31 22:24:11 | Views With Unions |
Previous Message | Robert Treat | 2003-07-31 21:59:37 | Re: surppressing column names in COPY format |