Date Operators

In the previous lessons, you saw how various operators work with numeric and string values. Although you can use the comparison operators with date values in the same way as numbers and strings, you must use a special syntax to perform arithmetic on date values.

Representing Dates and Times

A date value in MySQL takes the format YYYY-MM-DD or YYYYMMDD. Times take the format HH:MM:SS or HHMMSS. Until stored to the database or passed as an argument to a date function, however, this value is simply a string representation of a given date.

Date and Time

You can have both date and time components in a single value, represented in the ...

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