Eg1. Suppose I have a day 4/30/07 .Then I need to get 4/27/07.
Eg2. Suppose I have a day 6/29/07 .Then I need to get 6/22/07.
An another and easier way is to use python-dateutil. To get the previous Friday :
>>> from dateutil.relativedelta import relativedelta, FR
>>> from datetime import datetime
>>> datetime(2015, 7, 8) + relativedelta(weekday=FR(-1))
datetime.datetime(2015, 7, 3, 0, 0)
And the next Friday :
>>> datetime(2015, 7, 8) + relativedelta(weekday=FR(+1))
datetime.datetime(2015, 7, 10, 0, 0)