Reputation: 934
This is my time stamp which I mentioned below, can someone tell me how to what is the format of it?
date_time_str = '2017-08-24T05:16:36.085Z date_time_obj = datetime.datetime.strptime(date_time_str, '%Y-%m-%d T%H:%M:%S.%f')
I tried this one, it gives error.
2nd question,
As a Type of date_time_str
is STRING
, can we make it to TIMESTAMP
?
is it possible in python?
because I want to add it into SQL as it needs type as "TIMESTAMP".
Thanks.
Upvotes: 0
Views: 381
Reputation: 672
If you just need to add a timestamp value to a TIMESTAMP field in sql you can do this.
import datetime
my_timestamp = datetime.datetime.now()
update your db with something like this...
f"UPDATE my_sql_table
SET Timfield = {my_timestamp} where id = 1"
Upvotes: 1