尝试插入表时发生错误

时间:2013-11-20 06:55:11

标签: mysql type-conversion date-conversion

我收到错误
Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string

在这个INSERT语句中:

INSERT INTO COMMITTE_MEMBERS(PLAYERNO, BEGIN_DATE, END_DATE, POSITION)
VALUES 
  (2, '1990-01-01', '1992-12-31', 'CHAIRMAN'),
  (2, '1994-01-01', 'NULL', 'MEMBER'),
  (6, '1992-01-01', '1994-12-31', 'SECRETARY'),
  (6, '1991-01-01', '1992-12-31', 'MEMBER'),
  (6, '1990-01-01', '1993-12-31', 'TREASURER'),
  (6, '1993-01-01', 'NULL', 'CHAIRMAN'),
  (8, '1994-01-01', '1994-12-31', 'TREASURER'),
  (8, '1991-01-01', '1993-12-31', 'SECRETARY'),
  (8, '1990-01-01', '1991-12-31', 'MEMBER'),
  (8, '1992-01-01', 'NULL', 'MEMBER'),
  (27, '1990-01-01', '1990-12-31', 'MEMBER'),
  (27, '1992-01-01', '1994-12-31', 'TREASURER'),
  (27, '1991-01-01', '1992-12-31', 'TREASURER'),
  (57, '1993-01-01', '1993-12-31', 'SECRETARY'),
  (95, '1994-01-01', 'NULL', 'TREASURER'),
  (112, '1992-01-01', '1992-12-31', 'MEMBER'),
  (112, '1994-01-01', 'NULL', 'SECRETARY')

可能出现什么问题?

1 个答案:

答案 0 :(得分:0)

尝试 STR_TO_DATE(您的日期,'%m /%d /%Y') 在你的约会栏上。

像这样:

INSERT INTO COMMITTE_MEMBERS(PLAYERNO, BEGIN_DATE, END_DATE, POSITION)
VALUES 
  (2, STR_TO_DATE('1990-01-01', '%m/%d/%Y'), '1992-12-31', 'CHAIRMAN')