I have a loop, that goes through some entries. In the loop I’m getting creation date and I need to find if there were entries inserted on the same day. So for example if creation date = 2011-08-31 21:19:14.345, I need to select all rows where the creation date is between 2011-08-31 00:00:00.000 and 2011-08-31 23:59:59.999
How do I do this with SQL?
Without any other schema details, and if this is SQL Server 2K8+, you could do this:
By converting to a
dateinstead of working withdatetimeyou lose the time component and “normalize” how you’re comparing the values.Another way to lose the time component for comparison purposes is:
You would use that if you don’t have the
datedata type.