I'm trying to turn a string into a datetime object, however, I don't know what format I should use. No matter what I try I get this error: time data '2022-02-19 16:58:39.937000' does not match format <"the format I input">. Do you know what format I have to use for this date: "2022-02-19 16:58:39.937000"?
CodePudding user response:
To turn a string into a datetime object you need to do this:
import datetime
origin = '2022-02-19 16:58:39.937000'
time_converted= datetime.datetime.strptime(origin, "%Y-%m-%d %H:%M:%S.%f")
print(type(time_converted))
<class 'datetime.datetime'>
Your problem must be the separation between the formatting.