I'm supposed to get the excel date of Dec 1 2011 and what day of the week it is and print it out in this format. The Excel date for Thursday, 2011-Dec-1 is 40878. I've been able to get both, but I don't think my method of getting the day using if statements is the best approach. This is my Original script file, so please forgive the roughness. I've checked and I know my solution are right. My only problem is getting a more efficient way to get the day and any suggestions on how to get the month in my final output. We haven't done the date time module yet,so I can't experiment with that.
here is my code:
Year=2011
Month=12
Day=1
Y2=Year-1900
en=int((14-Month)/12)
Y3=Y2-en
m2=Month+12*
l=1+min(Y3,0)+int(Y3/4)-int(Y3/100)+int((Y3+300)/400)
d1=int(-1.63+(m2-1)*30.6)
import math
d2=math.floor(Day+Y3*365+l+d1) #d2 is the final excel date.
Day_Of_Week=((d2%7)-1)
print "%s"%(d2)
if Day_Of_Week==0:
print "sun"
if Day_Of_Week ==1:
print "mon"
if Day_Of_Week==2:
print"tue"
if Day_Of_Week==3:
print "wed"
if Day_Of_Week==4 :
print "thur"
if Day_Of_Week==5:
print "fri"
if Day_Of_Week==6:
print "sat"
Any Help will be appreciated :)