March 2, 2016 at 1:44 pm
I need a time that is greater than 4:00pm. I tried this without much luck.
I get Incorrect syntax near '>'.
SELECT cast(convert(char(8), [time], 108) as time) > (cast('16:00' as time))
FROM Table1
How is it supposed to be done? Help!
March 2, 2016 at 1:48 pm
if [time] is a datetime type just cast it as time
SELECT CAST(GETDATE() AS TIME)
March 2, 2016 at 1:56 pm
I believe you are going about it wrong. Your comparison needs to be in a WHERE clause:
SELECT [time]
FROM Table1
WHERE CAST([time] AS time) > (CAST('16:00' AS TIME))
GO
Now I haven't tested that and having the function on the left side of the comparison will void indexes...but that should get you on the right track.
-SQLBill
March 2, 2016 at 2:00 pm
I feel really stupid, THANK YOU.
March 2, 2016 at 2:01 pm
imba (3/2/2016)
I feel really stupid, THANK YOU.
No need to feel stupid...sometimes we all overlook the obvious.
-SQLBill
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply