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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -