title: [Repost] Error when updating the database - Data truncation Incorrect datetime value
date: 2021-07-13 10:44:46
comment: false
toc: true
category:
- Database
tags: - Repost
- Update
- Database
- Error
- Data
- truncation
- incorrect
- datetime
- value
- MySQL
- Solution
Solution#
Just change the time type of the corresponding column in the data table from timestamp to datetime.
Principle#
Due to the time type in the database, this error occurs when retrieving and displaying DATETIME values in the format of YYYY-MM-DD HH:MM:SS. The supported range is from 1000-01-01 00:00:00 to 9999-12-31 23:59:59, while the range supported by TIMESTAMP values is from 1970-01-01 08:00:01 to 2038-01-19 11:14:07 for storage. If a value is not within this range for TIMESTAMP, this error will be reported.