Avatar of allenkent
Flag for United States of America

asked on 

SQL 2008 - Date Filter for TODAY and TODAY-30 Days

I have this date format in my view (table) :  2017-03-10 13:45:16.567

I am trying to get today only in my view. I have tried the following:

SELECT     TOP (100) PERCENT DateCompleted
FROM         dbo.tblSuperDateChecker
WHERE     (DateCompleted = RTRIM(CONVERT(char(10), GETDATE(), 101)))

SELECT     TOP (100) PERCENT DateCompleted
FROM         dbo.tblSerialMasterPending
WHERE     (DateCompleted = CONVERT(Varchar(8), GETDATE(), 112))

I have piece of data that should be showing: (here is date filter removed). The top line should display because today is the 10th
2017-03-10 13:45:16.567
2017-03-09 13:45:13.550
2017-03-09 13:45:10.540
Microsoft SQL Server 2008

Avatar of undefined
Last Comment

8/22/2022 - Mon