Figuring out first day of a month

  • Thread starter MrGillig
  • Start date
  • #1
4
0

Main Question or Discussion Point

Hey guys!

Say I have a date. Let's just take todays date 05/04/2009.

And say I have numbers 0 - 6 corresponding to each day of the week ie. Sunday is 0, Monday is 1 etc.

From just knowing the day of the date, in this case 5, and that today is a Sunday, is it possible to calculate what the first day of the month was? By using the numbers that correspond to each day, of course.

So, I'll reiterate: from just knowing that its the 5th and that it's a Sunday (0), is it possible to figure out what the first day of the month was?
 

Answers and Replies

  • #2
290
2
Let today be the dth day of the month, and the day of the week be w. The weekday of the first day of the month is the least residue of [tex]w-(d-1)[/tex] mod 7 and in general, the weekday of the kth day is the least residue of [tex]w-(d-k)[/tex] mod 7.
 
  • #3
4
0
I'm confused. If I were to plug the values in for today would they then be "0 - (5+1) % 7". When I calculate this I seem to get -6, which isn't Wednesday. Did I mess up the calculation somewhere?

EDIT: Just read your edit sorry. Gonna try again.
 
  • #4
4
0
Sorry man but I'm still confused. If I plug in the values for today, for instance, I get -4. Should I be counting from 1 instead of 0 for the days of the week ie. Sunday is 1, Monday is 2 etc?
 
  • #5
CRGreathouse
Science Advisor
Homework Helper
2,820
0
Sorry man but I'm still confused. If I plug in the values for today, for instance, I get -4. Should I be counting from 1 instead of 0 for the days of the week ie. Sunday is 1, Monday is 2 etc?
-4 = 3 (mod 7).
 
  • #6
4
0
Ah I realise now how to equate it to correspond to the day of the week. If it happens to be below 0, I add 7 and get the result for the number corresponding to the first day of the month.

Thanks for the help!!
 

Related Threads on Figuring out first day of a month

  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
3
Views
2K
Replies
6
Views
707
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
2
Views
1K
Replies
6
Views
2K
  • Last Post
Replies
3
Views
2K
Replies
6
Views
4K
  • Last Post
Replies
3
Views
2K
Top