I am having some trouble writing a select statment that involves time.
I have a field, which has time data (i.e Jan 08 2008 12:00AM)
If I write my select statement like the following
select * from db where date < (select convert(char(12), getdate()) || '12:00')
, the sql works fine.
However, now I have a variable @startTime which has value Jan 1 1900 12:00. I only wants to get the time.
So, I change my statement to the following
select * from db where date < (select convert(char(12),getdate()) || select convert(char(5), @startTime, 12))
For some reason, it gives me the following error message (syntax error near select)
Does anyone know why my statement doens't work anymore?