Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 date/time format...

Author  Topic 

giro
Starting Member

8 Posts

Posted - 2003-12-16 : 21:15:21
Greetings to all,

I've a table that is used to store a member's login info. One of the items stored is data/time of login. I would like to use that information to compute the number of members online, say, in the last 5 mins from the current time.

So the MySQL statement should be something like:

SELECT * from members_data where (INTERVAL BETWEEN TIME STORED AND CURRENT TIME IS 10 MINS)

What's the appropriate format to store such a data/time information?

Thanks!

skillile
Posting Yak Master

208 Posts

Posted - 2003-12-16 : 22:41:32
SELECT interval
FROM members_data
WHERE inteval > DATEADD(n, -10, GETDATE() )

This should do the trick

Go to Top of Page

giro
Starting Member

8 Posts

Posted - 2003-12-17 : 00:19:15
Thanks, skillile!

I tried the following and it seems to work:

# timed is a TIMESTAMP column
# Find names of members who logged during the last 20 minutes from
# the table members

SELECT names FROM members WHERE (NOW()-INTERVAL 20 MINUTE < timed);
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-12-17 : 07:46:58
This is a SQLServer forum, by the way, not MySQL ...

- Jeff
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-12-17 : 12:10:51
quote:
Originally posted by jsmith8858

This is a SQLServer forum, by the way, not MySQL ...

- Jeff



How close are the syntaxes? Do they have a DATEADD?

http://www.dbforums.com/f5/



Brett

8-)
Go to Top of Page
   

- Advertisement -