Pacific-Design.com

    
Home Index

1. Python

2. Calendar

Python / Calendar /

Find Last Friday

#!/usr/bin/python
import datetime, calendar

lastFriday = datetime.date.today( )
oneday = datetime.timedelta(days=1)

while lastFriday.weekday( ) != calendar.FRIDAY:
    lastFriday -= oneday

print lastFriday.strftime('%A, %d-%b-%Y')