A while ago I created a code snippet in C for the same question. Solving this question with Python is a lot simpler, and on top of that Python takes care of impossible dates with the appropriate error message.

# find the day of the week of a given date
# Python will trap impossible dates like (1900, 2, 29)
# tested with Python24     vegaseat    01aug2005

from datetime import date

# a typical birthday  year, month, day 
# or change it to your own birthday... 
birthday = date(1983, 12, 25)

dayList = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
# date.weekday() returns 0 for Monday and so on, so pick the day string from the dayList
print "The day of the week on %s was a %s" % (birthday.strftime("%d%b%Y"), dayList[date.weekday(birthday)])

hi,

I don't know if this is supported in python 2.4 already or not, but I'm using python 3.1.

Alternative code:

from datetime import date

birthday = date(1983, 12, 25)

print('The day of the week on %s was a %s' % (birthday.strftime('%d%b%Y'), birthday.strftime('%A')))
The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.