Re: [INTERFACES] [off topic] Date and time fields

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: Matthew Hagerty <matthew(at)venux(dot)net>
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] [off topic] Date and time fields
Date: 1999-03-09 04:15:59
Message-ID: 36E4A07F.BFFC4480@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Brett W. McCoy 1999-03-09 04:26:15 Re: [INTERFACES] Perl Interface(Pg.pm) -- How to free $result
Previous Message Ken J. Wright 1999-03-08 23:47:53 PSQLODBC error