Selecting records of last two days:
-
Hi I want to select records from last two days, the following query does not return any record. select * from tablename where datefield = dateadd(day,-2,Getdate()) Any help will be appreciated.
Shahzad Aslam Software Engineer
-
Hi I want to select records from last two days, the following query does not return any record. select * from tablename where datefield = dateadd(day,-2,Getdate()) Any help will be appreciated.
Shahzad Aslam Software Engineer
The = sign is your problem. Try >=, otherwise you're only asking for records that have exactly the same time as today, but two days ago.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi I want to select records from last two days, the following query does not return any record. select * from tablename where datefield = dateadd(day,-2,Getdate()) Any help will be appreciated.
Shahzad Aslam Software Engineer
Try the following solutions: 1) use the abbreviations 'd' OR 'dd' inplace of day in your syntax. 2) Check out your table. Are you storing your data alongiwth the time in the database. If yes then this query will never return any result Thanks, Vikash Kumar Singh
vikash