I have a JSON file that I would like to change all the date string in date types. Now my script saves through the JSON dictionary and write these values in a database. How do I execute my string for conversion on whole string?
My code snippet is here that ends with objects. I would like to change my created date from "" 02/17/2015 16:53:25 ""
to
"2015-02-17 16:53:25"
I now created the CreatedDate = datetime.datetime.strptime (created date, "% m /% d /% Y% H:% M:% S ")
to get the output of the latter, I create the decoded 2 ['response'] ['listoff service'] ['service request'] for CreateDate
How to execute it on the code below SRAddress = sr ['SRAddress'] Latitude = SR ['Latitude'] Longitude = SR ['Longitude'] SRNumber = SR ['SRNumber'] First Name = SR ['First Name'] LastName = sr ['LastName'] HomeProject = SR ['Homephone'] Created Date = SR ['Created']
Maybe I can misunderstand, but can not you use it striptime
to convert your date back to the string with the required format?
def Convert_dataStress (s_date_in): date_in = datetime Datetime.datetime.strftime (date_in, "% Y-% m-% d% H:% M: for datetime.strptime (s_date_in,"% m /% d /% decoded 2 ['response'] []: ['ListOfServiceRequest'] ['ServiceRequest']: sr ['created date'] = convert_date (sr ['created date'])
No comments:
Post a Comment