Forum Moderators: open
I am using "WHERE fld_date_time = '20040901'" which displays no records although I have a database entry with 01/09/2004 13:30:00
If I put "WHERE fld_date_time < '20040901'" I see records so it is obviously querying OK.
Any ideas?
SELECT something FROM yourtable WHERE (CONVERT(smalldatetime, CONVERT(varchar, fld_date_time, 101), 101) = CONVERT(smalldatetime, CONVERT(varchar, GETDATE(), 101), 101))
It's converting dates to type varchar, then converting both to smalldatetime to easily compare. There may be a better (read: more efficient) way to do this, but it worked for me.