Introduction
Dealing with dates
6. DATE: The T-SQL default format
Working with time data
Date and time date
Extracting dates and times
Doing arithmetic with dates
Converting date and time data
Current date and time data
Building date and time data from parts
Summary and review

Instruction

Good. As you saw, dates are shown in the following format, which is the default SQL Server format:

YYYY-MM-DD

First we have the year, then the month, and finally the day. Be aware, though, that SQL Server has other date formats as well. We'll discuss how to change the default date format later in this course.

The DATE data type in SQL Server has a range of 0001-01-01 to 9999-12-31. The default value for this data type is 1900-01-01.

If we want to use dates in our queries, we need to enclose them with single quotes, like this:

SELECT
  Id,
  Model
FROM Aircraft
WHERE ProducedDate = '2012-04-05';

This query will return the ID and model numbers for all aircraft produced on April 5, 2012.

Exercise

Select the Id, Model, and ProducedDate data for all aircraft built on April 6, 2008 or March 1, 2010.

Stuck? Here's a hint!

You will need two conditions joined with OR. Remember the proper date format and use quotes: 'YYYY-MM-DD'.