SQL – Select using current day…

I’ve had this problem a few times, and many people always ask me it… so here it is immortalised.

If you require to select all records added to your table for the current day use the following where clause – obviously ‘col’ should be the name of your datetime column…

Hope this helps you all as much as it has myself!

select *
from mytable
where datediff(day,getdate(),col)=0 and col <= getdate()

Leave a Reply

The reCAPTCHA verification period has expired. Please reload the page.