pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to display a unixtimestamp from a timestamp record?
2+ messages / 2 participants
[nested] [flat]
* How to display a unixtimestamp from a timestamp record?
@ 2001-01-15 15:56 Marcelo Bartsch <bartschm@psi.com>
0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Bartsch @ 2001-01-15 15:56 UTC (permalink / raw)
To: pgsql-sql
Hello!
again i was faced to a problem i was trying to do create view in wich i
had the next fields:
CREATE TABLE "tbacct" (
"user_name" character varying(32),
"nas_identifier" character varying(15),
"nas_port" int4,
"acct_session_id" character varying(15),
"caller_id" character varying(16),
"called_station_id" character varying(16),
"framed_ip_address" character varying(15),
"acct_disconnect_cause" character varying(40),
"acct_session_time" int4,
"acct_timestamp" timestamp,
"realm" character varying(64)
);
and i need view in wich acct_timestamp is a int8
USERNAME
IP-ADDRESS
74
000B2E5B
NULL
6572
IP-ADDRESS
NULL
4
2000-11-13 14:19:45-03
REALM
and i want it to be displayed something like this:
USERNAME
IP-ADDRESS
74
000B2E5B
NULL
6572
IP-ADDRESS
NULL
4
974135985
REALM
i know it is possible using date_part
select date_part( 'epoch' , timestamp '2000-11-13 14:30:40');
gave the right answer . but when i executte
select user_name, date_part( 'epoch' , timestamp 'acct_timestamp') from
tbacct limit 2;
it said ERROR: Bad timestamp external representation 'acct_timestamp'
how should i represent date_part( 'epoch' , timestamp 'acct_timestamp')
to work?
Thanks in Advance
--
Marcelo Bartsch R.
bartschm@psi.com
PSINet Chile
/O /Ot Minimize execution speed (default)
Microsoft C/C++ Compiler Documentation,
'Enviroment and Tools', p531
Telefono : +56-2-3979000
Numero de Fax : +56-2-3979090
Numero de eFax : (815) 366-3177
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: How to display a unixtimestamp from a timestamp record?
@ 2001-01-15 17:41 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: Marcelo Bartsch <bartschm@psi.com>
0 siblings, 0 replies; 2+ messages in thread
From: Stephan Szabo @ 2001-01-15 17:41 UTC (permalink / raw)
To: Marcelo Bartsch <bartschm@psi.com>; +Cc: pgsql-sql
> select user_name, date_part( 'epoch' , timestamp 'acct_timestamp') from
> tbacct limit 2;
>
> it said ERROR: Bad timestamp external representation 'acct_timestamp'
> how should i represent date_part( 'epoch' , timestamp 'acct_timestamp')
> to work?
select user_name, date_part ('epoch', acct_timestamp) from tbacct limit 2;
should work... the single quotes are making a literal string value, so
your query is saying take the epoch of the timestamp represented by the
literal 'acct_timestamp' rather than the value of the field.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-01-15 17:41 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-15 15:56 How to display a unixtimestamp from a timestamp record? Marcelo Bartsch <bartschm@psi.com>
2001-01-15 17:41 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox