I have a table that registers visitors to a website. I want to count how many have visited my website on each day.

My problem is that I can’t figure out how to typecast the datetime value so that it doesn’t use the entire date field when making a distinct count.
Can anyone explain this?
For some reason I assumed you were using SQL Server. If that is not true, please let us know. I think the
DateDiffmethod could work for you in other DBMSes depending on the functions they support, but they may have better ways to do the job (such asTRUNCin Oracle).In SQL Server the above method is one of the fastest ways of doing the job. There are only two faster ways:
Intrinsic
int-conversion rounding :If using SQL Server 2008 and up, this is the fastest of all (and you should use it if that’s what you have):
When SQL Server 2008 is not available, I think the method I posted is the best mix of speed and clarity for future developers looking at the code, avoiding doing magic stuff that isn’t clear. You can see the tests backing up my speed claims.