Ms sql compare hours as integer

My where clause is throwing errors when I try to see if the hour is after 20.

where datepart(Hour,RecordedDate) > 20

where cast(format(RecordedDate,'HH') as int) >20 

without the where clause the query works fine.

Works for me in MS SQL. Which SQL Server are you using? What’s the data type of RecordedDate and what error are you receiving?

the sql bridge module , not sure of the year, ms sql

it is a datetime variable
I can see the hours when I use the operators on it in the select section, or get the date if I try to

the error is

GatewayException: Incorrect syntax near the keyword 'where'.
	caused by SQLServerException: Incorrect syntax near the keyword 'where'.

Can you post the full SQL statement? It looks like you have 2 WHERE statements.

1 Like

lol I just figured that out too

thanks so much, sorry

1 Like