I am running an sql query in python.
TIMEDIFF()
It gives me the result just fine.
<class 'tuple'> (datetime.timedelta(days=-1, seconds=86332),)
I want to convert this to be only seconds.
I tried to add the seconds as interval into my query but it cannot be run that way.
Select Timediff(second, ...)
I also tried DATEDIFF, not worked.
After I add the 'second' the query cannot be executed
So, I want to calculate in pyton the difference, if no other solution.
(datetime.now() - datetime.now()).total_seconds()
of course, in reality using different times You can get the timedelta
object from the tuple using indexing:
td = result[0]
then get the number of seconds using the timedelta
object's total_seconds
method.
seconds = td.total_seconds()