473,320 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Who's online?

I have a table of users and a table consisting of logins which I'm joining together. I'm trying to query the users who have logged in within the past 20 minutes. I've been attempting to use the datediff function such as:
DateDiff("M", MyDateTime1, MyDateTime2)
but I'm unclear about a couple of things.

One, does the dateDiff function account for different years and hours, meaning does the datediff function drop year and days and only looks at the minutes?

For example, say I have an entry at:
08/01/2007 10:10:10 and
08/01/2008 10:20:10
and assume the datetime now is 08/01/2008 10:22:10. Would the results returned be 2 or 1?

Is there a better function to use? If so, what is it and I'll research it.

Thank,
Red
Aug 28 '07 #1
4 1189
Purple
404 Expert 256MB
Hi Red and welcome to TSDN MSSQL forum,

can I direct you first to the microsoft reference on the datediff function here .

From your description the function will do what you need, take a read and ask back for clarification

Regards Purple
Aug 28 '07 #2
Thank you for the link!
Aug 28 '07 #3
Okay, so I read the MS reference and the very first sentence,

datepart
Is the parameter that specifies on which part of the date to calculate the difference.
sounds as if it ONLY subtracts the datepart only and that is disregards the other parts...

e.g. if you are searching for the datepart of month, then the year and seconds are disregarded. Is this a true statement?
Aug 28 '07 #4
ck9663
2,878 Expert 2GB
Okay, so I read the MS reference and the very first sentence,


sounds as if it ONLY subtracts the datepart only and that is disregards the other parts...

e.g. if you are searching for the datepart of month, then the year and seconds are disregarded. Is this a true statement?
The DATEDIFF function calculates the period of time in dateparts between the second and first of two dates you specify.

DATEDIFF(datepart, date1, date2)

This function will result a date2-date1 in date parts. It returns the interval between the two dates depending on what datepart you're trying to get.

if you want the number of days between date1 and date2 try DATEDIFF(dd, date1, date2). it will return the number of days.

if you want the number of weeks between date1 and date2 try DATEDIFF(wk, date1, date2). it will return an integer representing the number of weeks between the two dates.

so depending on what you're trying to get, you have to change the datepart parameter. if you read past the first sentence, you would know ;)
Aug 29 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: szar | last post by:
Anyone know a good way to check if someone is signed in, has a session going, etc.? I could have a signed in field that updates from 'yes' to 'no' when they sign out, but that wouldn't work well...
7
by: B.Dimple | last post by:
Hi Oracle Experts, How can I check the Users who are online ? Is there a table name which contains a list of DB users (e.g in SQLServer the table is sysusers) ? B.Dimple Junior DBA
5
by: Steph | last post by:
Hi, I would like to be able to know who is actually connected on the website i am creating. The users are stored in a sql server table (to enter, they have to be identified on the login.aspx...
24
by: tom c | last post by:
I have gotten great help in this forum. I am working by my self, developing with a new technology, and it would be extremely time consuming and frustrating without this forum. So who are the...
36
by: makanewalou | last post by:
Who is Jesus? Without a doubt, you have often heard the claim that Jesus is God, the second person in the "Holy trinity." However, the very Bible which is used as a basis for knowledge about...
10
by: Breana | last post by:
Ok i found this a while back and i am trying to mod it so it works but it keeps not updating the users online and kills my other code? Well i got it working but it dont update when i login?...
2
by: Ken Fine | last post by:
Sorry if this is off-topic but I can't find a better MSFT-managed newsgroup for the question. I'm looking for contact info for Microsoft's campus rep for the University of Washington in Seattle....
6
by: ryan2345 | last post by:
Hi, I have made a website wherein the user creates his account. Then the user can login into his account, update his account, search for people with different key skills. Theres also a discussion...
3
by: javedsai | last post by:
I'm building an application where I want "Who's online?" section i.e those whoever are logged in Access application must display in home page. For example If user 'A' and user 'B' is logged in then,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.