View Full Version : Date Time Question
08-16-2005, 06:18 PM
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!
08-16-2005, 06:43 PM
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'
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??
08-16-2005, 07:29 PM
I don't think DateDiff is supported in MySQL, I know at least it isn't in 4.0.x and before.
What you could do, and you'll probably want to look this up in the manual because I might not have the syntax exactly right is this:
Select user from accounts WHERE DATE_ADD(date, INTERVAL 15 MINUTE) < Now() ORDER BY use
Which basically says select any timestamp with 15 minutes added to it that is still in the past. (Hopefully that made sense)
08-16-2005, 07:37 PM
DateDiff is supported in MySQL after some version or another.
08-16-2005, 07:38 PM
hmm, ok i'll look into that some more,,
and i guess the syntax is wrong,, still getting an error from that code:
08-18-2005, 05:37 PM
timelessfifteen = dateadd("m",-15,now())
SELECT X from X WHERE X >= '"& timelessfifteen &"' ORDER BY X
08-18-2005, 08:35 PM
I use a similar command for my applications as oracleguy and it works fine:
SELECT username FROM usertable WHERE lastonline_time >= DATE_ADD(now(), INTERVAL - 15 MINUTE)
Select all username from usertable where lastonlinetime is newer or equal to current time substracting 15 minutes.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.