defrex defrex - 1 year ago 96
Python Question

How can I subtract a day from a Python date?

I have a Python

object. What is the best way to subtract one day?

Answer Source

You can use a timedelta object:

from datetime import datetime, timedelta

d = - timedelta(days=days_to_subtract)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download