Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 RETURN RESULTS ONLY FROM PREVIOUS DATE

Author  Topic 

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2014-04-27 : 18:03:52
i have a table with 4 columns phone_number, extension, Name, last_update_date. Say i have 200 hundread records in that table, which is updated daily, so if i run my query today 4-26-2016 i should only get results from 4-25-2014 (based on my query below). When i run the follwing no results are returned even though there are records form the previous day. Please advise. note my last_update_date has a datatype of datetime, so my results should return in datatime).or lets say i want to retun only the max(last_updated_date)

select * from my_table 3 where last_update_date = getdate()-1

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2014-04-27 : 18:17:54
i answerd my own question. i came up with select * from my_table3 where cast(last_update_date as date) = cast(getdate()-1 as date)
Go to Top of Page
   

- Advertisement -