pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedWhat Am I Doing Wrong?
3+ messages / 2 participants
[nested] [flat]
* What Am I Doing Wrong?
@ 2005-10-18 19:38 Lane Van Ingen <lvaningen@esncc.com>
2005-10-18 21:20 ` Re: What Am I Doing Wrong? Lane Van Ingen <lvaningen@esncc.com>
2005-10-18 23:39 ` Re: What Am I Doing Wrong? Michael Fuhr <mike@fuhr.org>
0 siblings, 2 replies; 3+ messages in thread
From: Lane Van Ingen @ 2005-10-18 19:38 UTC (permalink / raw)
To: pgsql-sql
I have been trying to subtract two timestamps from each other to determine
the difference between the two timestamps (current time and a past timestamp
called 'updated_time') IN SECONDS, but no luck.
The trouble I am having is getting the first timestamp, representing the
current time, to translate to seconds; have tried different commands (now(),
localtimestamp, current_timestamp, etc)
What am I doing wrong? Sample statement and error message is below:
------------------------------------------
select EXTRACT(EPOCH from TIMESTAMP current_timestamp) - EXTRACT(EPOCH from
TIMESTAMP updated_time) ::integer
ERROR: syntax error at or near "current_timestamp" at character 37
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: What Am I Doing Wrong?
2005-10-18 19:38 What Am I Doing Wrong? Lane Van Ingen <lvaningen@esncc.com>
@ 2005-10-18 21:20 ` Lane Van Ingen <lvaningen@esncc.com>
1 sibling, 0 replies; 3+ messages in thread
From: Lane Van Ingen @ 2005-10-18 21:20 UTC (permalink / raw)
To: pgsql-sql
Ignore my request. The solution is:
---------------------------
computeIfUptime() -------------------------------------
select (EXTRACT(EPOCH from TIMESTAMP 'now') - EXTRACT(EPOCH from TIMESTAMP
'2005-10-18 17:00:00'))::integer
-----Original Message-----
From: Lane Van Ingen [mailto:lvaningen@esncc.com]
Sent: Tuesday, October 18, 2005 3:39 PM
To: pgsql-sql@postgresql.org
Subject: What Am I Doing Wrong?
I have been trying to subtract two timestamps from each other to determine
the difference between the two timestamps (current time and a past timestamp
called 'updated_time') IN SECONDS, but no luck.
The trouble I am having is getting the first timestamp, representing the
current time, to translate to seconds; have tried different commands (now(),
localtimestamp, current_timestamp, etc)
What am I doing wrong? Sample statement and error message is below:
------------------------------------------
select EXTRACT(EPOCH from TIMESTAMP current_timestamp) - EXTRACT(EPOCH from
TIMESTAMP updated_time) ::integer
ERROR: syntax error at or near "current_timestamp" at character 37
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: What Am I Doing Wrong?
2005-10-18 19:38 What Am I Doing Wrong? Lane Van Ingen <lvaningen@esncc.com>
@ 2005-10-18 23:39 ` Michael Fuhr <mike@fuhr.org>
1 sibling, 0 replies; 3+ messages in thread
From: Michael Fuhr @ 2005-10-18 23:39 UTC (permalink / raw)
To: Lane Van Ingen <lvaningen@esncc.com>; +Cc: pgsql-sql
On Tue, Oct 18, 2005 at 03:38:54PM -0400, Lane Van Ingen wrote:
> select EXTRACT(EPOCH from TIMESTAMP current_timestamp) - EXTRACT(EPOCH from
> TIMESTAMP updated_time) ::integer
>
> ERROR: syntax error at or near "current_timestamp" at character 37
What are you intending "TIMESTAMP" to do? If you're trying to do
a cast then see "Type Casts" in the documentation for the correct
syntax:
http://www.postgresql.org/docs/8.0/interactive/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS
You might not need a cast at all:
test=> SELECT extract(epoch FROM current_timestamp);
date_part
------------------
1129678734.81522
(1 row)
--
Michael Fuhr
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-10-18 23:39 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-18 19:38 What Am I Doing Wrong? Lane Van Ingen <lvaningen@esncc.com>
2005-10-18 21:20 ` Lane Van Ingen <lvaningen@esncc.com>
2005-10-18 23:39 ` Michael Fuhr <mike@fuhr.org>
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