| From: | Peter Nixon <listuser(at)peternixon(dot)net> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | CAST INTERVAL to INT?? |
| Date: | 2003-07-31 20:53:16 |
| Message-ID: | bgbvj3$uv5$1@main.gmane.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Treat | 2003-07-31 21:13:34 | Re: surppressing column names in COPY format |
| Previous Message | Tom Lane | 2003-07-31 20:50:37 | Re: surppressing column names in COPY format |