Database Reference
In-Depth Information
columnname DATE
You can insert a date into a date column using any of the methods described in Chapter
11, however the DATE datatype does have a limited range. Dates can be stored from 1
January 1000 through to 31 December 9999. That range should be adequate for most of us!
TIME
The TIME datatype is used to store a time value or period. It can range from -838 hours to
838 hours. This enables you not only to store the time of day, but also to store a long length
of time in this column type.
A TIME column is declared without attributes as follows:
columnname TIME
Normally the output of the time column would be “HH:MM:SS”, however when you are
storing an hour value of over 99 hours the format will allow an extra hour digit to allow the
measurement of this longer time period.
YEAR
The YEAR datatype allows you to store a year with very limited storage space. You specify a
year column by using:
columnname YEAR
The YEAR that you store in this type of column can range from 1901 to 2153. The small
range is due to the YEAR being stored in a single byte. The best way of inserting a date into
this column is by specifying a string with 4 digits, for example:
1952
2010
2063
If you only use two digits, MySQL has to make a decision about what year you are refer-
ring to. For more information about how it chooses you can consult the section in the
online MySQL manual. MySQL will always output the contents of the YEAR datatype with
4 digits to avoid confusion.
Other Types
All of the previous datatypes will have been used to store data that you are familiar with,
like dates, times and numbers. MySQL also supports other types that you may be less famil-
iar with. Two of these are described below.
Search WWH ::




Custom Search