Seems like this comes up a lot so I thought I’d blog about a clean way I found to do this from a StackOverflow article. Basically, the problem is if you have a bunch of Sql records that have date and times in them (not 00:00:00 for time), using Microsoft’s SqlServer. You may want to query all records that are on a certain date. You can certainly for a query that looks like: SELECT * FROM VolunteerJobs WHERE JobStartTime >='08-01-2008' AND JobStartTime<='08-14-2008 23:59:59.996'
However, this feels a little awkward. A better way that I plan on using is:
SELECT *FROM VolunteerJobWHERE DateAdd (day, datediff(day, 0, JobStartTime), 0) = '2010-10-09'
Somehow, it … Continue Reading