-1

Could you please help me with how to convert the string value '6/4/2020' to date?

My CSV file's timestamp column also comes in different string values, such as

4/6/2013

12/20/2019

1/17/2020.

Yi .D
  • 49
  • 5
  • Did you do any research? Python has built-in functionality for parsing strings to dates. – jonrsharpe Jun 04 '20 at 19:48
  • Did you look at the [datetime](https://docs.python.org/3/library/datetime.html) docs? – roganjosh Jun 04 '20 at 19:48
  • see https://stackoverflow.com/help/how-to-ask; what have you tried, and what isn't working? If it's homework, https://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions – Kirk Jun 04 '20 at 19:51

1 Answers1

0

In MySQL (totally independent of Python), we can convert a string to a DATE or DATETIME datatype using the STR_TO_DATE function, documented in the MySQL Reference Manual

as a demonstration

SELECT STR_TO_DATE( '4/6/2013' ,'%m/%d/%Y') AS mydate

Reference: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_str-to-date

spencer7593
  • 106,611
  • 15
  • 112
  • 140