Skip to content
Advertisement

Check if datetime is in current date

I am using SQLServer 2008. I have a table X with field Y that is a datetime format. In the WHERE statement of my query I only want to keep the rows where the date of field Y equals the current date.

I have searched the internet but couldnt find an example that works for SQLServer/

Thank you for your help!

Advertisement

Answer

Try this:

WHERE CONVERT(DATE, Y) = CONVERT(DATE, getdate())
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement