user6167266 user6167266 - 1 year ago 139
SQL Question

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.

Answer Source

You could try something like this

SELECT * FROM TABLE WHERE DateField = CONVERT(smalldatetime,dateadd(MINUTE,100,getdate()),120)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download