Select Records based on Year

  • DECLARE @Date

    SET @Date = 2012

    DECLARE @Year int

    SET @Year = (SELECT DATEPART(yyyy,@Date))

    SELECT @Year AS Year

    --SELECT *

    -- FROM [Orders].[dbo].[Orders] od

    -- WHERE .Orderl_Date < @Date;

    ----WHERE DATEPART(yyyy,@Date)= @Year

    ----WHERE DATEPART(yyyy,od.Order_Date)= @ArchiveYear

  • Duplicate post. No replies please

    Replies to http://www.sqlservercentral.com/Forums/Topic1712220-3077-1.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply