Data1234
Data1234

Reputation: 97

How to convert date to datetime?

I have this type of date '20181115 0756' and also in a diffent dataframe in this format '2018-11-15'. I would like to know if there is any way to convert it to datetime without the hours and minutes

date['DATE']= pd.to_datetime(date.DATE)

this converts it to 218-11-15 00:00:00 and I'd like to avoid that

What I trying to do is to calcuate the time difference between the dates in the two dataframes that I have

Thank you in advance

Upvotes: 1

Views: 2681

Answers (1)

Todd Burus
Todd Burus

Reputation: 983

You can use the following code

date['DATE'] = pd.to_datetime(date['DATE'], errors='coerce').dt.date

Upvotes: 2

Related Questions