Tags
Before you can effectively query date/time (or temporal) data, you have to know something about how date/time values are stored. SQL Server supports two date/time data types: datetime and smalldatetime. This article explains in detail the differences between the two, talks about the performance effect of database design on querying, and teaches how to search by time and by time.
by Bryan Syverson, author of Murach’s SQL for SQL Server
Suppose you’re writing a query to find all the invoices that were written on January 6, 2003. You know from the control totals that 122 invoices were written that day. But when you run this query:
SELECT * FROM Invoicesthe result set is empty. What’s going on?
WHERE InvoiceDate = '2003-01-06'
How dates and times are stored in SQL Server