Getting Correct Results from Date Comparisons
The discussion about string inequalities got us started in understanding date comparisons. In fact, I avoided addressing dates at all until you understood inequalities. That's because almost all date processing on SQL Server is done with inequalities, not equalities.
SQL Server doesn't really store dates. It stores datetime data, which is a composite data type made up of date information and time information. There are two data types for storing dates: datetime and smalldatetime. Both types consist of a date component and a time component.
In Transact-SQL, all dates are quoted strings formatted as dates and/or times. (We'll look at some date functions tomorrow in the section "Using Functions.") The ...
Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.