Date function

  • Hi,

    I want to pull data from the database table which has been updated today. For ex: select firstname, lastname from users where updatedate <= GetDate().

    This pulls all records from the table. I just want the names that has been updated only today. How can i do that??

    Thanks

  • unikhath (9/10/2008)


    Hi,

    I want to pull data from the database table which has been updated today. For ex: select firstname, lastname from users where updatedate <= GetDate().

    This pulls all records from the table. I just want the names that has been updated only today. How can i do that??

    Thanks

    Try this:

    select

    firstname,

    lastname

    from

    users

    where

    updatedate >= dateadd(dd, datediff(dd, 0, getdate()), 0)

    and updatedate <= getdate();

    😎

  • Thanks, thats working.

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

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