We help IT Professionals succeed at work.

Date_Time Field in SQL Query (T-SQL)

I am some what new to SQL and am trying to query a table that has a date_time field in it and filter by that date_time field. The field shows the date and then the time that the line was written to the database.. i.e. '2001-10-31 15:35:24.000'.

My question is how do I get all data that happened on a specific day (like 10-31-2011) regardless of what the time is?

Thank you in advance for any help with this.
Watch Question

This is one option.

   YourDateField BETWEEN '10/31/2011 00:00:00' AND '10/31/2011 23:59:59'


Thank you very much. This is a new system for me and the previous system I used didn't track the time...it was all set to 00:00:00 so I never had to worry about the time part.

Thanks again.
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

better check this article out to do things correctly:

above will eventually fail in some setups ...

Explore More ContentExplore courses, solutions, and other research materials related to this topic.