What is 2038 problem? Why MySQL doesn’t support date beyond 2038

2038 Problem is an issue with MySQL where timestamp type fails to store dates beyond 2038. The bug is also called Unix Millenium Bug / Y2K38 (analogous to Y2K). This might cause our program to fail on or before 2038 (while handling date beyond it) 

Cause of the problem

This happens because of the Unix epoch (number of seconds after January 1 1970 00:00:00 GMT) will exceed the maximum value of 32 bit signed integer. Thus the time beyond 03:14:07 UTC on Tuesday, 19 January 2038 will be stored as a negative number. The result will be, interpreting the date as December 13, 1901 instead of 2038.

Possible solutions

  • Try using longer datatypes (64-bit should do the job) – Read more about this issue in 64-bit systems
  • Use DATE or DATETIME types in places of TIMESTAMP. (Note that only the TIMESTAMP will store timezone information. In other words, DATETIME column does not store timezone information)
  • Wait for MySQL drivers to fix this bug

Read more about the bug report here

Read more about the problem and its solution on Wikipedia

Leave a Reply