May 28, 2010 at 7:35 am
The below script give output for last 7days, I need to modify the script like to pull the data for particular period, i mean mention date period(for eg: 05/01/2010 to 05/26/2010), Kind of new to this, I appriciate the help.
SET @accountID = 1
SET @BeginDate = DateAdd(dd,-7,getdate()) -- last week
SET @EndDate = getdate() -- currentdate
SELECT T1.abcID, T2.AccountuserDisplayID, T1.abcDateTime into #temp_users FROM [abc] T1
INNER JOIN T2 ON T1.abcID = T2.userID AND T1.StatusID IN (1,2) -- Active, Idle
INNER JOIN [UserAccount] T3 ON T2.userID = T3.userID AND T3.ACCOUNTID = @accountID
Select AccountuserDisplayID, abcDateTime AS 'abc DateTime' from #temp_users
Drop Table #temp_users
May 28, 2010 at 7:46 am
SET @accountID = 1
SET @BeginDate = '20100505 23:59' -- yyyy-mm-dd hh:mm:ss[.mmm]
SET @EndDate ='20100505 23:59' -- yyyy-mm-dd hh:mm:ss[.mmm]
-edit- just so you know, I haven't read your query. Just noticed that @BeginDate and @EndDate were set at the top to 'current date' and 'current date - 7days'.
May 28, 2010 at 9:55 am
You need a WHERE clause.
select x
from mytable
where somedate > @begdate and somedate < @enddate
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply