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!

1
2
3
SELECT *
FROM mytable
WHERE datediff(DAY,getdate(),col)=0 AND col <= getdate()

Leave a Reply