Day of Week

Thread Solved

Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 137
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Day of Week

 
0
  #1
Aug 1st, 2005
Is there a way to get the day of the week when supplied with a date? Like November 11, 1911 may be a Monday?
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Day of Week

 
0
  #2
Aug 1st, 2005
you might find some good info here
http://www.daniweb.com/techtalkforum...ad20774-2.html
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,005
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 928
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: Day of Week

 
0
  #3
Aug 1st, 2005
Python does make it look simple ...
  1. # day of the week of a given date
  2. # date.weekday() returns 0 for Monday and so on, so pick the string from a list
  3.  
  4. from datetime import date
  5.  
  6. oldDate = date(1911, 11, 11) # year, month, day
  7.  
  8. dayofWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
  9. print "The day of the week on %s was a %s" % (oldDate.strftime("%d%b%Y"), dayofWeek[date.weekday(oldDate)])
Last edited by vegaseat; Sep 23rd, 2008 at 11:53 pm. Reason: replace disfunctional php tags
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC