how to get last two weeks data.

  • hello,

    I want to get created Last Two Week Data in Sql Server.

    Is this query Correct.

    SELECT ContactId,FirstName,MiddleName,LastName,CreatedOn

    FROM Contact

    WHERE CreatedOn >= DATEADD(day,-14, GETDATE())

    Thanks For The Help.

    immad

  • Depends.

    Right now it is for example 10:28AM.

    With your query you won't find data before 10:28AM two weeks ago.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • try this: select DATEADD(dd,-14,CONVERT(datetime,CONVERT(nvarchar(11),GETDATE())))

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

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