DECLARE @UserId INT; SET @UserId = ##UserId##; DECLARE @F...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @UserId INT;
SET @UserId = ##UserId##;
DECLARE @FirstDay DATE;
SET @FirstDay = ( SELECT MIN(CreationDate) FROM Users WHERE Id = @UserId );
DECLARE @LastDay DATE;
SET @LastDay = ( SELECT MAX(LastAccessDate) FROM Users WHERE Id = @UserId );


SELECT DATEDIFF( DAY, @FirstDay, @LastDay )

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results