script

  • 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

  • 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'.


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • 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