Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts

    Question Date Time Question

    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

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    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

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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:

    Code:
    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)
    OracleGuy

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    DateDiff is supported in MySQL after some version or another.

    http://dev.mysql.com/doc/mysql/en/index.html
    http://dev.mysql.com/doc/mysql/en/da...functions.html

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    hmm, ok i'll look into that some more,,
    and i guess the syntax is wrong,, still getting an error from that code:

    http://www.remixwars.com/admin/date.asp

  • #6
    New Coder
    Join Date
    May 2004
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    timelessfifteen = dateadd("m",-15,now())
    SELECT X from X WHERE X >= '"& timelessfifteen &"' ORDER BY X

  • #7
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I use a similar command for my applications as oracleguy and it works fine:

    Code:
    SELECT username FROM usertable WHERE lastonline_time >= DATE_ADD(now(), INTERVAL - 15 MINUTE)
    Description:
    Select all username from usertable where lastonlinetime is newer or equal to current time substracting 15 minutes.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •