MySQL #1292 - 不正确的日期值:'0000-00-00'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37292628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
#1292 - Incorrect date value: '0000-00-00'
提问by urfusion
I referenced many questions which have the same title as mine, but they have a different approach and different issue so this question is not a duplicate.
我引用了许多与我的标题相同的问题,但它们有不同的方法和不同的问题,所以这个问题不是重复的。
I have a table in which column
fm_sctrdate
is a date
type and has the default value 0000-00-00
.
我有一个表,其中column
fm_sctrdate
是一个date
类型并且具有默认值0000-00-00
。
Insertion by website is working fine but when I try to insert any value by phpmyadmin
then I got following error.
通过网站插入工作正常,但是当我尝试插入任何值时,phpmyadmin
出现以下错误。
Mysql
version is 5.7.11
. One more thing recently our server has been upgrade from mysqlnd 5.0.12
to 5.7.11
.
Mysql
版本是5.7.11
. 最近的另一件事是我们的服务器已从 升级mysqlnd 5.0.12
到5.7.11
.
Here is the query
这是查询
INSERT INTO `iavlif_fmp_clientquote` (`jm_cqid`, `fmsq_id`, `fmsg_id`,
`fm_sctrdate`, `fm_sctrtime`, `fm_sctbaggage_weight`,
`fm_sctfreight_weight`, `fm_sctpassenger`, `fm_sctinfant`,
`fm_sctinfant_details`, `fm_sctinfant_dob`, `fmtp_id`, `fmtpi_id`,
`jmcnt_id`, `fm_name`, `fm_company`, `fm_email`, `fm_phone`, `fmts_id`,
`jmts_id`, `fm_pax_nbr`, `fm_hours_nbr`, `fmqt_id`, `fmtr_id`,
`fm_sctnotes`, `fm_locdepart`, `fm_locarrive`, `fm_sctconsignment_weight`,
`fm_sctconsignment_dimensions`, `fm_sctconsignment_desc`, `fm_sctdangerous`,
`fm_scturgent`, `fm_sctspecial_instructions`, `fm_sctquote_type`,
`fm_sctwork_type`, `fm_sctreoccuring`, `fm_sctaccommodation`, `fm_sctcar`,
`fm_recdate`, `fm_recenddate`, `fm_recfrequency`, `fm_rectime`,
`fm_medical`, `fm_medical_details`, `fm_user_ip`, `fm_dang_details`,
`fm_sctsubstance`, `fm_sctpurchase_number`, `fm_role_id`, `fm_myrole_id`,
`jm_myrole_id`, `fm_sctwork_point`, `fm_locdepartarrive`, `fm_sctnbr`,
`fm_dateCreated`, `fm_cc`, `fm_gl`, `fm_timeCreated`, `jm_qtid`, `jmtp_id`,
`jmtpi_id`, `jmsg_id`, `jms_id`, `jmsq_id`, `fms_id`, `fmcq_id`) VALUES
(NULL, '1', '1', '0000-00-00', '1', '1', '1', 'sdfasd', 'No',
'sdafdsafdsaf', 'dsfas', 'sdfasd', 'dsafds', '0', 'asdfds', 'sdfasd',
'sdfads', 'sdaf', 'sdaf', 'sdaf', '0', '0', '0', '1sadfasdsda', 'sdfadsf',
'as', 'as', 'as', 'asas', 'asd', 'No', 'No', 'adsfsd', 'eqwrqew', 'qewrqew',
'No', 'No', 'No', '0000-00-00', '0000-00-00', 'ewqr', 'qewrw', 'No', 'eqwr',
'ewqr', 'qewr', '', '', '', '', '', '', '', '0', '0000-00-00', '', '',
'00:00:00.000000', '', '', '', '', '', '', '', NULL)
We started facing this issue just after upgrade of mysql
我们在升级后就开始面临这个问题 mysql
回答by KuKeC
回答by Amit Garg
You have 3 options to make your way:
1. Define a date value like '1970-01-01'
2. Select NULL from the dropdown to keep it blank.
3. Select CURRENT_TIMESTAMP to set current datetime as default value.
您有 3 个选项可供选择:
1. 定义一个日期值,如“1970-01-01”
2. 从下拉列表中选择 NULL 以将其保留为空白。
3. 选择 CURRENT_TIMESTAMP 将当前日期时间设置为默认值。
回答by TomerM
@user2823136, you wrong.
@ user2823136,你错了。
After reviewing MYSQL 5.7 changes, MYSQL stops supporting zeros value in date / datetime.
在查看 MYSQL 5.7 更改后,MYSQL 停止支持日期/日期时间中的零值。
It's not correct to use zeros in date or in datetime, just put null instead of zeros.
在日期或日期时间中使用零是不正确的,只需将零而不是零。
Thanks
谢谢