I am currently writing some SQL and have run into an odd problem.
Used code:
select * from #table1 where datefield = DATEADD(day, -2, getdate())
The problem I am facing will not output such information. If I add '>' to '=', it will pull out the information. If I put the exact date in the request instead of "dateadd", it pulls out the correct entries.
I tested the date parameters, and there are corresponding entries for 4/10/2011. But for some reason it just doesn't like '= dateadd' in this case.
I also tried using the string 'current_timestamp' instead of 'getdate' also with the same results.
Any suggestions?
source share