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
DATETIMEsupports “1000-01-01 00:00:00” to “9999-12-31 23:59:59,” but theTIMESTAMPsupports “1970-01-01 00:00:01” to “2038-01-19 03:14:07” UTC. - The
DATETIMEis constant, but theTIMESTAMPvalues change based on the timezone the application uses because theTIMESTAMPdata 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:
SOCIAL SHARE CARD GENERATOR