PDA

View Full Version : Date Time Question


angst
08-16-2005, 06:49 PM
this was posted in ASP, but i've mosted it here.

first post:

Hello,
I'm trying to show what users are currently logged in on my site. what I've done is update a timestamp everytime they hit a page. what i want to do is select users where the current time Now() is within 15 minutes of the timestamp, to see if any users are on.

but I'm not sure how to do this.
any ideas? examples would be grate, I haven't done any asp in a long time.

thanks in advance for you time!
-Ken

second post:

ok, i've tried this,

SQL = "Select user from accounts WHERE DateDiff(n, Now(), date) < 15 ORDER BY user"


but i'm getting an error:

ADODB.Recordset.1 error '80004005'

SQLState: 42000
Native Error Code: 1064
[TCX][MyODBC]You have an error in your SQL syntax near '(n, Now(), date) < 15 ORDER BY user' at line 1


/admin/date.asp, line 6


also i'm using MySQL as the data base.

any ideas, anyone??

thanks again!
-Ken

nikkiH
08-16-2005, 07:31 PM
What's n?

And DateDiff for MySQL takes 2 args, not 3.
DATEDIFF() returns the number of days between the start date expr and the end date expr2. expr and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.

raf
08-17-2005, 12:08 AM
when you want a good time-function, then you best specify which MySQL version you are running because quite a few usefull functions were added with the latest version.

anyway, i would do it like this:

SELECT user FROM accounts WHERE UNIX_TIMESTAMP() - UNIX_TIMESTAMP(date) < 900