DATEPART WITH YEAR AND MONTH

  • Hi all how do I query datepart to include month also when passing a variable from my app. My attempt below

    WHERE (DATEPART(yyyy, @date1) = DATEPART(yyyy, Docket_Date) AND (DATEPART(m, @date1) = DATEPART(m, Docket_Date)))

  • WHERE

    Docket_Date >= DATEADD(MONTH, DATEDIFF(MONTH, 0, @date1), 0) AND

    Docket_Date < DATEADD(MONTH, DATEDIFF(MONTH, 0, @date1) + 1, 0)

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

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

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