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.
| 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 intervalFROM members_dataWHERE inteval > DATEADD(n, -10, GETDATE() )This should do the trick |
 |
|
|
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 membersSELECT names FROM members WHERE (NOW()-INTERVAL 20 MINUTE < timed); |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-12-17 : 07:46:58
|
This is a SQLServer forum, by the way, not MySQL ... - Jeff |
 |
|
|
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/Brett8-) |
 |
|
|
|
|
|