wierd_dave
asked on
From "01/01/1900" to "monday". How???
Given a date, how can I work out the day of the week?
Since I'm in England and we do dates as dd/mm/yy, I want to enter a date, for example 15/04/1976 and the function to return a value for Thursday (which was the day of the week for 15/04/1976 if I remember). The way I'm thinking would probably work but it would be so long that it would just be dumb to use. No grace or finesse. Come on, astound me.
I think this could be hard so there's 200 points riding on it!
Since I'm in England and we do dates as dd/mm/yy, I want to enter a date, for example 15/04/1976 and the function to return a value for Thursday (which was the day of the week for 15/04/1976 if I remember). The way I'm thinking would probably work but it would be so long that it would just be dumb to use. No grace or finesse. Come on, astound me.
I think this could be hard so there's 200 points riding on it!
int dd=1;
int mm=1;
int yy=1900;
int jdn;
char *weekday[]={"Tuesday","Wed nesday","T Hursday"," Friday","S aturday"," Sunday","M onday"};
if( mm < 3 ){ mm += 12; yy -= 1; }
jdn = dd+1720996+(mm+1)*306/10+y y*365 + yy/4 - yy/100 + yy/400;
printf("%s\n",weeday[jdn%7 ]);
int mm=1;
int yy=1900;
int jdn;
char *weekday[]={"Tuesday","Wed
if( mm < 3 ){ mm += 12; yy -= 1; }
jdn = dd+1720996+(mm+1)*306/10+y
printf("%s\n",weeday[jdn%7
ASKER
Sorry ahTri, that was fairly much the way I was thinking. I was going to work out the number of days from 01/01/1900 and use the remainder as you said to get the date.
Rejection seems so negative, but i've tried ozos' method and it is far batter than I would have some up with.
If ozo wants to submit an answer, they can have the 200 points.
Thanks to both of you.
Rejection seems so negative, but i've tried ozos' method and it is far batter than I would have some up with.
If ozo wants to submit an answer, they can have the 200 points.
Thanks to both of you.
I have written a program to work out what day of the week it is on any specific date, in that there is a function that tells you the day number from 1900...
Well? Interested?
Well? Interested?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If u think this way work I will send u the set of objects to calculate the number of days from one day to another. Sorry for your 200 points if u not satisfy with this answer