Mysql Date Field exception Data truncated for column Processing

Source: Internet
Author: User

 

The supported range of mysql date types is 1000-01-01 to 9999-12-31.

 

The supported range of the datetime type is 1000-01-01 00:00:00 to 9999-12-31 23:59:59.

 

If you try to insert a value out of the range into the database, an error in the title will be reported.

 

There are two effective solutions:

 

1. Check the date range in the program. If the range is exceeded, a prompt or other processing is given.

 

2. Find SQL-mode = "STRICT_TRANS_TABLES, NO_AUTO_Create_USER, NO_ENGINE_SUBSTITUTION" in my. ini of the mysql installation directory"

 

Remove STRICT_TRANS_TABLES and restart mysql.

 

When the second method is used, when the date range is exceeded, no error will be reported when the database is inserted, but it will be 0000-00-00 or 0000-00-00 00:00:00

 

From Lwei's blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.