user6167266
user6167266

Reputation: 41

smalldatetime comparison SQL Server

I have a smalldatetime field in my SQL database. The SQL format for this is type is : yyyy-mm-dd hh:mm:ss

I need to query my database and request all records where the date matches today's date AND the time portion is 100 minutes from the present time.

Help with the SQL would be greatly appreciated.

Thank you.

Upvotes: 0

Views: 929

Answers (2)

Quinn Favo
Quinn Favo

Reputation: 86

Since the other answer didn't work for me, I am including an alternative below:

SELECT * FROM TABLE WHERE cast(DateField as date) = cast(getdate() as date)

Upvotes: 0

DBNinja
DBNinja

Reputation: 308

You could try something like this

SELECT * FROM TABLE WHERE DateField = CONVERT(smalldatetime,dateadd(MINUTE,100,getdate()),120)

Upvotes: 2

Related Questions