Date and Time

MySQL has a range of data types for handling date and time information. Time formats have an intuitive order that you're used to in daily life: hours:minutes:seconds. Dates, on the other hand, are always output in the format: year:month:day. Both conform to ANSI-92 standard format.

All date and time data types have a range of legal values and a “zero” value to which a field will be set if you attempt to put an illegal value into it.

When outputting date and time, you usually have the option to ask MySQL to give you the data in either string or numeric form. The format depends on the context in which it's used in your SQL.

MySQL is flexible when accepting date and time information. For example, the date 2003-05-12 means the same ...

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.