Timedelta is not defined
You've imported datetime, but not defined timedelta. You want either:
from datetime import timedelta
or:
subtract = datetime.timedelta(hours=options.goback)
Also, your goback parameter is defined as a string, but then you pass it to timedelta as the number of hours. You'll need to convert it to an integer, or better still set the type
argument in your option to int
instead.
Where you have timedelta
, you need to put datetime.
before it, so it's actually datetime.timedelta