Convert SQL datetime to python datetime
--------------------------------------------
Solustion:
- Import datetime
- set sql datetime to a variable
- set sql datetime formate
- convert it to python date time usign datetime
Step 1: Import datetime
import datetime
Step 2: Set sql date to a variable -
sql_datetime = '2013-01-12 15:27:43'
formate = '%Y-%m-%d %H:%M:%S'
Step 3: Convert the sql datetime to python using datetime as bellow -
datetime.datetime.strptime(sql_datetime,formate)
datetime.datetime(2013, 1, 12, 15, 27, 43)