0

I can't seem to get this piece of code to work. I am trying to load some csv into my MySQL database. The time stamp is in string format, I am trying to save it as a time stamp.

LOAD DATA LOCAL INFILE 'C:/tmp/test1.csv'
INTO TABLE eurusdtrue16
FIELDS TERMINATED BY ','
    ENCLOSED BY ''
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(str_to_date('20151110 12:07:43.786','%Y%m%d %H:%i:%s.%f'),
 1.001, 1.002);

It shows error

Syntax error: missing closing parenthesis

2
  • What is the purpose of the str_to_date call in this context? Commented Mar 10, 2016 at 22:55
  • to save the the string time stamp as a real time stamp in mysql Commented Mar 10, 2016 at 22:55

1 Answer 1

2

The error is

(str_to_date('20151110 12:07:43.786','%Y%m%d %H:%i:%s.%f'),
^  this parenthesis does not have a match.

I doubt this will work, but it is worth trying giving fixed field lengths:

'20151110 12:07:43.786','%4Y%2m%2d %H:%i:%s.%f'

Probably, since there is no date portion delimiter, you'll have to break it down using substr():

substr('20151110', 0, 4) +  ' '  +
substr('20151110', 4, 2) +  ' '  +
substr('20151110', 6, 2) +
' 12:07:43.786','%Y%m%d %H:%i:%s.%f'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.