1
$\begingroup$

I have a excel data with time stamp format like this "2019-06-10T14:05:00+05:30" [YYYY-MM-DDTHH:MM:SS], I want it to be converted into "2019-06-10 14:05" [YYYY-MM-DD HH:MM],

Is it possible to convert into required format using Excel or Python Libraries? or any other way?

Thank you!

$\endgroup$
  • $\begingroup$ one way is storing the data as dataset and changing the format of column date-time with string rules. $\endgroup$ – Fatemeh Asgarinejad Jun 24 '19 at 9:42
2
$\begingroup$
  • Using python's pandas library
  • strftime() helps obtain specific format
  • to_datetime() of pandas helps convert string to datetime object
import pandas as pd
dt = "2019-06-10T14:05:00+05:30"
dt = pd.to_datetime(dt, errors='ignore')
transformed_date = dt.strftime("%Y-%m-%d %H:%M")
print(transformed_date)
print(type(transformed_date))
dateType = pd.to_datetime(transformed_date)
print(type(dateType))
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.