Day of Week
Is there a way to get the day of the week when supplied with a date? Like November 11, 1911 may be a Monday?
bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
Python does make it look simple ...
# day of the week of a given date
# date.weekday() returns 0 for Monday and so on, so pick the string from a list
from datetime import date
oldDate = date(1911, 11, 11) # year, month, day
dayofWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
print "The day of the week on %s was a %s" % (oldDate.strftime("%d%b%Y"), dayofWeek[date.weekday(oldDate)])
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417