Greater than TimeStamp

  • 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!

  • if [time] is a datetime type just cast it as time

    SELECT CAST(GETDATE() AS TIME)

  • 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

  • I feel really stupid, THANK YOU.

  • 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