views:

389

answers:

2

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
My reason in using TIMESTAMP is that it automatically converts the date value based on the database connection's timezone setting.
Chad Johnson
+1  A: 

TIMESTAMP shouldn't be used for literal date/time values, it is for SQL Server synchronization.

Use SMALLDATETIME or DATETIME.

richardtallent
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