Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Elapsed

Status
Not open for further replies.

Ed75

MIS
Sep 29, 2004
27
US
This should be easy but I'm having a tough time with it.

What I need is to find out how much time has elapsed since a certain user last executed a process on the server and return the number of minutes.



SELECT last_batch
from sysprocesses
where hostname = 'Server1'
and loginame = 'johndoe'
and last_batch > '2007-09-13 11:00:00.000'

Thanks...
 
You will want to use datediff.

Code:
SELECT last_batch, datediff(dd, last_batch, getdate())
from sysprocesses
where hostname = 'Server1'
and loginame = 'johndoe'
and last_batch > '2007-09-13 11:00:00.000'

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
No problem.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top