Does anyone know of a workaround for storing values outside of the range '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC in a MySQL TIMESTAMP field?
+3
A:
If you alter the column to use the DATETIME type, you can store a wider range of values.
the TIMESTAMP type's range is '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC.
the DATETIME type's range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.
John Douthat
2009-06-16 16:48:35
My reason in using TIMESTAMP is that it automatically converts the date value based on the database connection's timezone setting.
Chad Johnson
2009-06-16 16:49:55
+1
A:
TIMESTAMP shouldn't be used for literal date/time values, it is for SQL Server synchronization.
Use SMALLDATETIME or DATETIME.
richardtallent
2009-06-16 16:49:24
Plus, it automatically converts the date to the timezone set for the connection. Pushing this conversion to the database level, out of the code level, makes a LOT of sense and prevents a LOT of potential bugs.
Chad Johnson
2009-06-16 16:56:14