0

I am getting the error
Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string

on this INSERT statement:

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')

What could be wrong?

Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
  • possible duplicate of http://stackoverflow.com/questions/14119133/conversion-failed-when-converting-date-and-or-time-from-character-string-while-i – R R Nov 20 '13 at 06:56
  • Try to run this from mysql command line console, and show us real MySQL error message. ...but, your query is correct. – Devart Nov 20 '13 at 06:57

1 Answers1

0

Try STR_TO_DATE(yourdatefield, '%m/%d/%Y') on your datecolumn.

Like this:

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')
Sashi Kant
  • 13,277
  • 9
  • 44
  • 71