0

I have a column with datetime UTC date

2020-01-01 00:00:00+00:00   

Can someone help me to convert it to just datetime64 for eg:

2020-01-01 
user6016731
  • 382
  • 5
  • 18
  • Could you share some more details, e.g. how do you read this column in your python code? Is that a string or some builtin db date type? what is your database system? – Pac0 May 29 '20 at 09:33
  • if you use pandas (this seems to be the case) you can change it like that: df.dates.apply(lambda x: x.date()) – S.A May 29 '20 at 09:34

2 Answers2

1

if you use pandas (this seems to be the case) you can change it like that:

df.dates.apply(lambda x: x.date()) # where dates is your datetime column
S.A
  • 201
  • 1
  • 10
0

Try the datetime package with Python 3.2+.

import datetime
a='2020-01-01 00:00:00+00:00'
print (datetime.datetime.strptime(a,'%Y-%m-%d %H:%M:%S%z').strftime('%Y-%m-%d'))
Prateek Dewan
  • 1,587
  • 3
  • 16
  • 29