str_to_date的mySQL错误日期时间值错误?

时间:2017-11-16 22:41:12

标签: mysql sql string datetime

此错误来自此代码,我无法弄清楚错误是什么;

#1411 - 日期时间值不正确:'晚上11:00'对于函数str_to_date

CREATE TABLE OWNS (
STUDNO       NUMERIC(9) NOT NULL,
ENAME         CHAR(30) NOT NULL,
TYPE          CHAR(15) NOT NULL,
OTIME         TIME,
ODATE         DATE,
ODRTN         VARCHAR(7) NOT NULL,
CONSTRAINT OWNS_FOREIGN_KEY FOREIGN KEY (STUDNO) REFERENCES STUD(STUDNO));

INSERT INTO OWNS (STUDNO, ENAME, TYPE, OTIME,ODATE, ODRTN)
VALUES(123456789,'The Lion King','Anti', str_to_date('11:00 PM', '%l:%i 
%p'), STR_TO_DATE('16-jan-2011', '%d-%b-%y'), 3)

感谢帮助谢谢!!!

2 个答案:

答案 0 :(得分:0)

INSERT INTO OWNS (STUDNO, ENAME, TYPE, OTIME,ODATE, ODRTN)
VALUES(1234456789,'The Lion King','Anti', str_to_date('11:00 PM', '%l:%i 
%p'), STR_TO_DATE("16-jan-2011", "%d-%b-%Y"), 3)

答案 1 :(得分:0)

尝试'%h:%i%p'作为时间的掩码。我总是用'%h'几个小时。