Need to pull data from table having datetime colum

  • Hi all,

    I want to pull data for only today on a table having datetime column.

    Please help

  • DECLARE @Today DATE = GETDATE();

    WHERE <the datetime column> >= @Today and <the datetime column> < DATEADD(dd,1,@Today)

    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
  • Hi

    I am unable to fetch data using that query is that the complete query or do i need to do any changes in it.

    i couldn't see any select in that .I am new to this so i don't know much.

  • Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'WHERE'.

  • m.rajesh.uk (4/8/2016)


    Hi

    I am unable to fetch data using that query is that the complete query or do i need to do any changes in it.

    i couldn't see any select in that .I am new to this so i don't know much.

    You will need to incorporate the above WHERE clause into your SELECT query and use your table/field names.

  • m.rajesh.uk (4/8/2016)


    I am unable to fetch data using that query is that the complete query or do i need to do any changes in it.

    Maybe start with a basic SQL tutorial, if you don't even know the form of a query.

    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 6 posts - 1 through 5 (of 5 total)

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