dateadd in where clause

  • I have a table with the a datetime filed that holds dates. when i run the following query against it no data is returned.

    select * from member_time where mamber_time.date = dateadd(dd,-1,GETDATE())

    what is incorrect the table has data for yesterday

  • Assuming your column has just dates, you will have to convert the result from the dateadd function to just a date, since by default it also includes the time.

    where member_time.date = convert(date, dateadd(dd,-1,GETDATE()))

    Edit, plus you misspelled the table name in the where clause, compared to what you have in the from clause.

  • thanks that works.

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

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