How to Strip Time from Date Time and store in PSQL using Python? -
i have situation want strip time date time object , store in database (psql precisely)
how do ?
>>> print(datetime.now()) 2016-06-28 16:22:30.918715
what want
2016-06-28
and store psql database
what best way handle ?
i posting answer cause took me around hour find answer , hope helps someone. best solution of have found
dt = datetime.today() 2016-06-28 16:22:30.918715 dt.strftime('%y-%m-%d') 2016-06-28
basically psql stores data in type string code dt.strftime('%y-%m-%d') strip off time , return string data type , can store it.
Comments
Post a Comment