Date and Time Types

This section lists the column types for storing dates and times. No special attributes can be declared for these column types, and only the global attributes (for example, NULL, NOT NULL) are applicable.

DATE

Description: Date in the format YYYY-MM-DD

Range: 1000-01-01 to 9999-12-31

Zero value: 0000-00-00

Required storage: 3 bytes

TIME

Description: Time in the format hh:mm:ss

Range: -838:59:59 to 838:59:59

Zero value: 00:00:00

Required storage: 3 bytes

DATETIME

Description: Date and time in the format YYYY-MM-DD hh:mm:ss

Range: 1000-01-01 00:00:00 to 9999-12-31 23:59:59

Zero value: 0000-00-00 00:00:00

Required storage: 8 bytes

YEAR

Description: Year in the format YYYY

Range: 1901 to 2155

Zero value: 0000

Required storage: ...

Get Sams Teach Yourself MySQL 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.