I am working with python oracle connection. But i have a issue returning date with the cursor result as json.
below is the json result of the cursor, the issue is format of create_dttm. When creating a dataframe from this it is not changing the format. Any suggestion
result = cursur.execute("**my query**")
data = list(result)
final = json.dumps(data)
print(final)
[{"create_dttm": {"$date": 1677264505842}, "update_dttm": {"$date": 1677264505842}, "wo_id": "ABC-63953"},{"create_dttm": {"$date": 1677264505843}, "update_dttm": {"$date": 1677264505843}, "wo_id": "ABC-63954"}]
I want the data to be like below when creating a dataframe
create_dttm update_dttm wo_id
2021-5-09 2021-5-09 ABC-63953
2021-5-09 2021-5-09 ABC-63953
2
Answers
I created below function to help solve my question, used some parts from previous answer as well. But this works effeciently
You could do something like this:
Output:
Also see if there’s a way you can directly convert the milliseconds to date time format and then extract only the date from it.