pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feed[off topic] Date and time fields
2+ messages / 2 participants
[nested] [flat]
* [off topic] Date and time fields
@ 1999-03-08 22:39 Matthew Hagerty <matthew@venux.net>
1999-03-09 04:15 ` Re: [INTERFACES] [off topic] Date and time fields Thomas G. Lockhart <lockhart@alumni.caltech.edu>
0 siblings, 1 reply; 2+ messages in thread
From: Matthew Hagerty @ 1999-03-08 22:39 UTC (permalink / raw)
To: pgsql-interfaces
Greetings,
Sorry for the off topic post, but the pgsql-sql list has almost no traffic
and I have never received an answer there :(
Could someone give me a basic run down on how to use/do date and time
checking and comparing. For example, I want to know how long someone is
logged into my site, so each time they request a page I update a "time"
field in my table. How can I check to see if more than, say 5 or 10
minutes has passed? I've come to learn that is *can't* be as simple as
something like this:
select * from temp where (logintime + '10 minutes') < time 'now'::datetime;
Also, what is the double colon? I only use it here because I saw it used
all over in the online docs. ;)
Thank,
Matthew
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [INTERFACES] [off topic] Date and time fields
1999-03-08 22:39 [off topic] Date and time fields Matthew Hagerty <matthew@venux.net>
@ 1999-03-09 04:15 ` Thomas G. Lockhart <lockhart@alumni.caltech.edu>
0 siblings, 0 replies; 2+ messages in thread
From: Thomas G. Lockhart @ 1999-03-09 04:15 UTC (permalink / raw)
To: Matthew Hagerty <matthew@venux.net>; +Cc: pgsql-interfaces
> Could someone give me a basic run down on how to use/do date and time
> checking and comparing. For example, I want to know how long someone
> is logged into my site, so each time they request a page I update a
> "time" field in my table. How can I check to see if more than, say 5
> or 10 minutes has passed? I've come to learn that is *can't* be as
> simple as something like this:
> select * from temp
> where (logintime + '10 minutes') < time 'now'::datetime;
>
> Also, what is the double colon? I only use it here because I saw it
> used all over in the online docs. ;)
The double colon notation is a Postgres-ism which in this context is
leading to confusion. Use the SQL92-standard syntax as below. If
"logintime" is updated at each page access (and is a "datetime" type)
then your query
select * from temp
where (logintime + time '10 min') < datetime 'now';
should work to identify stale connections I would think. Feel free to
ask other questions. Have you looked at the html or hardcopy chapter on
data types? Not sure how many examples it has, but it does discuss some
issues I would think...
- Tom
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-03-09 04:15 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-03-08 22:39 [off topic] Date and time fields Matthew Hagerty <matthew@venux.net>
1999-03-09 04:15 ` Thomas G. Lockhart <lockhart@alumni.caltech.edu>
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