Mysql-problems encountered when adding data to MySQL using CURDATE ()

Source: Internet
Author: User
After the Info table is created in MySQL, an error is displayed when inserting data, mainly in the addtime field. The related code is as follows: # Create a table createtableitem (...... Addtimedatenotnull, endtimedatenotnull ,...... # Insert data INSERTINTOitem (item_name, item_remark, item_desc, kind_id, addtime, endtime, init_price, max_price, owner_id,... mysql

After the Info table is created in MySQL, an error is displayed when inserting data, mainly in the addtime field. The related code is as follows:
# Table creation
Create table item (
......
Addtime date not null,
Endtime date not null,
......
# Insert data
Insert into item (item_name, item_remark, item_desc, kind_id, addtime, endtime, init_price, max_price, owner_id, winer_id, state_id)
VALUES ('mainboard ', 'old mainboard', 'old mainboard, you can also use ', 1, CURDATE ()-5, CURDATE () + INTERVAL 30 DAY, 230,250, 1, null, 1 );

I checked that the CURDATE () function can be used as a string or as a digital context. There are also examples of defining it as a Date type, so I initially thought the code is okay.
However, the following error still occurred on my computer after I entered it:
ERROR 1292 (22007): Incorrect date value: '20140901' for column 'addtime' at row 1
Please kindly advise

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.