This article will give us a walk-through of different methods to compare datetime values in MySQL. In MySQL, we can store dates in DATE and TIMESTAMP data types. Both data types store data in the “YYYY-MM-DD” “HH:MM:SS” format. There are a few differences between both data types, such as:

The DATETIME supports “1000-01-01 00:00:00” to “9999-12-31 23:59:59,” but the TIMESTAMP supports “1970-01-01 00:00:01” to “2038-01-19 03:14:07” UTC.
The DATETIME is constant, but the TIMESTAMP values change based on the timezone the application uses because the TIMESTAMP data will convert the current time to UTC and vice-versa.

Differences Between Both Data Types

The following is a simple example that explains the difference between both data types:

Leave a Reply

Your email address will not be published. Required fields are marked *