A Quick Tip On How To Ignore Time When Querying From SqlServer

Posted by Peter Kellner on September 07, 2011 · 1 min read

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:


FROM VolunteerJob
(day, datediff(day, 0, JobStartTime), 0) =

Somehow, it just feels better.  HTH’s.