mysql日期截断,Mysql日期警告数据被截断

I'm having an interesting issue with Mysql DATE format.

I have this table :

| id | int(11) | NO | PRI | NULL | auto_increment |

| file_path | varchar(255) | YES | | NULL | |

| date_export | date | YES | | NULL | |

When i'm updating a row using the date function : NOW(), the date is updated with this format :

'2014-01-23'

But when i'm using another date format, like hand-written one like :

update backup_conf_allied set date_export='2014-23-01' where file_path='IDF-952584-SW1' ;

The date_export column transforms into :

'0000-00-00'

Warning table tells me that :

| Warning | 1265 | Data truncated for column 'date_export' at row 3628 |

Why? The date format is the same as NOW() function.

Thanks.

解决方案

Posted query

update backup_conf_allied set `date_export='2014-23-01'` where file_path='IDF-952584-SW1' ;

What it should be

update backup_conf_allied set `date_export='2014-01-23'` where file_path='IDF-952584-SW1' ;

MySQL Support DATE format as 'YYYY-MM-DD' , Year then Month then Date, So you are updating a Date column with wrong value "2014-23-01" , There are only 12 months in year, you are using month 23 which is invalid that's MySQL is converting it to ZERO DATE (0000-00-00)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值