CAST INTERVAL to INT?? - Mailing list pgsql-general

From Peter Nixon
Subject CAST INTERVAL to INT??
Date
Msg-id bgbvj3$uv5$1@main.gmane.org
Whole thread Raw
Responses Re: CAST INTERVAL to INT??  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi Guys

I am trying to cast a INTERVAL to an INT (or BIGINT) without much success.
The query I would like to do is (partially) the following:

UPDATE acct_table SET AcctSessionTime = (now()::timestamp with time zone -
AcctStartTime::timestamp with time zone -
'%{Acct-Delay-Time:-0}'::interval);

Obviously the %{variables}% are replaced with real values.
This code if for the FreeRadius Postgres DB backend. You can see it in
current CVS at:
http://www.freeradius.org/cgi-bin/cvsweb.cgi/radiusd/raddb/postgresql.conf

This query does exactly what I want, but it requires that the underlying
AcctSessionTime field be of type INTERVAL. This unfortunately breaks
backwards compatibility with alot of billing systems which use the same
code for MySQL/Postgres/Oracle etc...

What I need to do is the above calculation (and several others like it) but
store the resulting number of seconds in a BIGINT field. How is this
possible???

TIA
--

Peter Nixon
http://www.peternixon.net/
PGP Key: http://www.peternixon.net/public.asc

pgsql-general by date:

Previous
From: Robert Treat
Date:
Subject: Re: surppressing column names in COPY format
Next
From: Ron Johnson
Date:
Subject: Re: Transactions across multiples databases