温馨提示×

mysql的日期为空怎么处理

木子
858
2021-05-14 08:20:23
栏目: 云计算

mysql的日期为空处理方法:若录入日期中小时超过了12个小时,应把%h修改为%H。


mysql的日期为空怎么处理


具体实验案例如下所示:

select str_to_date('2016.08.22 13:46:12', '%Y.%m.%d %h:%i:%s'); --输出空

select str_to_date('08.09.2008 08:09:30', '%m.%d.%Y %h:%i:%s'); --输出'2008-08-09 08:09:30'

处理方法:将第二句中的%h修改为%H后输出结果正常:

select str_to_date('2016.08.22 13:46:12', '%Y.%m.%d %H:%i:%s');



0