-1

Basically I am getting Aug 11, 2017 type of date in scrapy. How to convert it to mysql date format like 2017-08-11 00:00:00 ?

  • 1
    Does this answer your question? [Parse date string and change format](https://stackoverflow.com/questions/2265357/parse-date-string-and-change-format) – nbk Mar 10 '20 at 18:35
  • What is the issue, exactly? Have you tried anything, done any research? Stack Overflow is not a free code writing service. See: [tour], [ask], [help/on-topic], https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users. – AMC Mar 10 '20 at 19:41

1 Answers1

0

You can insert your time string directly in mysql . Like

INSERT INTO TEST VALUES (CAST(STR_TO_DATE('Aug 11, 2017','%b %d,%Y') as DATETIME));;

example

CAST(STR_TO_DATE('Aug 11, 2017','%b %d,%Y') as DATETIME)
2017-08-11 00:00:00

It5 uses STR_TO_DATE to get a mysql date and then uses CAST to get a DATETIME.

you could use instead of CAST also DATE_FORMAT

nbk
  • 45,398
  • 8
  • 30
  • 47