Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Excellent article, and very useful for programming. For figuring out the day of the week in your head, there's a different (and very useful) trick. It uses the month and day from the Gregorian calendar, rather than the day number, because 99% of the time that's what you'll be wanting: "Which day of the week will August 31st, 2026 be?"

The trick is to notice that in any year, leap year or not, the following dates will be the same day of the week in any year: 4/4, 6/6, 8/8, 10/10, and 12/12. (Whether you use the month/day style favored in America, or the day/month style that the rest of the world uses, either way those dates are the same, which is convenient). Which day of the week those dates are will vary from year to year: this year (2026) those are all Saturdays, last year they were all Fridays, next year they will all be Sundays. But in any given year, those dates are separated by 63 days, a multiple of seven, so they are always going to be the same day of the week.

And that's not all: look at 5/9, 9/5, 7/11, and 11/7 — those are also that same day of the week! (Again, conveniently, this works whether you're using the American calendar style or the rest of the world). Those odd-numbered dates can easily be remembered with the mnemonic phrase "a 9-to-5 job at 7-11". And voila, you have memorized one "special" day in nine of the twelve months. (What you do for January, February, and March I will cover later).

Now I'll pause and explain why this is useful. Many of you have already made the intuitive leap to figure this out, but it's still useful to see it spelled out. If you're trying to figure out what day of the week a certain date, let's say August 31st, is going to be, then you find the "key" date for that month (August 8th), and remember that this year, those key dates are Saturdays. (I don't yet have a good mnemonic for easily remembering which key date is which for each year; I'd welcome suggestions if you can think of one). So, 8/8 was a Saturday. Therefore, August 15th and 22nd and 29th are Saturdays. Therefore, August 31st will be a Monday this year. All of that is math you can easily do in your head in seconds.

Now, January, February, and March. March is always the same in every year: March 7th. 14th, 21st, and 28th are the "key days" that are the same day as 4/4 et al. But the way I prefer to memorize March is that "March 0th" (which isn't actually in March, it's the last day of February) is the "key day". That still lets me do the mental math for March easily enough, but it also reminds me that Feburary 28th or 29th, depending on whether you're in a leap year, is the "key day" for this year. Finally, for January, I use January 3rd in non-leap-years and January 4th in leap years as the "key day" that I memorize; the number 4 is strongly associated with leap years, so "leap year = January 4th" is easy to memorize, and I just have to remember that it's one day less in non-leap-years, January 3rd.

And so I just have to memorize "January 3rd or 4th" and "March 0th", plus the phrase "a 9-to-5 job at 7-11". And I can easily figure out in my head what day of the week any day of the year will be. For example, December 25th will be a Friday this year: that took me three seconds to work out in my head without looking at a calendar.



I'm curious to understand what kind of life you live, or what you work with, when this information becomes so important that you need to be able to calculate it on whim, and fast too?

Personally whenever someone asks me if I'm available on some date, or what I'm doing at a specific day or whatever, almost never does it matter what day of the week is, it's more about what things I have planned, and for that I have to open the calendar regardless as events beyond 1+ week horizon is quickly filled into my "Blank" cabinet in the brain.

Not saying it isn't useful in the sense that avoiding these tiny hassles of "open calendar, find the date, look up what weekday" isn't worth it, I've unexplicitly trained myself to be ambidextrous for no real purpose except "that's neat", so I'd understand it, I'm mostly curious about actual usefulness of this in other's daily life, as seemingly my own looks very different from the ones where this'd be useful.


Like I said in answer to a similar question somewhere else in this thread, I rarely actually need to use this. But there have been times when it's come in handy, such as when I'm away from my computer and someone calls me on the phone to ask if I want to meet them for lunch on the 13th. I rarely remember my appointments by day of the month, but I do usually remember them by day of the week, i.e. I think "the 13th... (two seconds of mental math)... that's a Thursday. Right, I already made plans to have lunch with John Smith on Thursday next week." And then I can tell them "Sorry, I'm busy on the 13th, but I think I'm free on the 14th, let me check." And then I switch over to the calendar app, verify the 14th is free, and switch back to the phone app to confirm that I can meet them on Friday the 14th.

That's how I end up using this most often. (And "most often" is still just every couple of months, mind). I still need to use the calendar app to record my appointments, but it sometimes lets me give people a "no, I'm busy that day, how about (other day)?" response with less of a conversational pause.

So like you, I don't find it all that useful, but it still is nice to have from time to time. And I also just find it fun sometimes to know that the 13th of the month = Thursday without having to look anything up.


I’m not the person you asked and the technique I use is different (though also from an HN post).

https://news.ycombinator.com/item?id=40464664

I think I may prefer that one, because it also allows me to figure out people’s birthdays. The key insight to making that one faster is to realise you can precalculate and memorise the year value for the year you’re currently in. Granted, having to memorise 12 magic numbers for the months maybe makes that one harder, but for some reason I immediately memorised the table upon looking at it once.

To answer the question: I don’t really need to be able to do this, but I like it. It’s a fun, short, mental exercise. I even set up a daily reminder to quiz me on a random date every day.

But it is practically useful, and it surprised me in how often I use it. Someone tells me of an event that’s going to be on a certain date and without breaking conversation I can figure out what day of the week it’ll be. I still think I’m fairly slow (I tend to double-check myself), but can still do it consistently slightly faster than someone who needs to take their phone out.

Also, on a couple of occasions it has happened that as a group we needed to know a day of the week, someone checked it on their phone and made a mistake and I was able to catch it.


For me (not GP), this lives in the recreational-mathematics part of my brain rather than the useful-things part of my brain: John Conway called this invention of his the “Doomsday rule”[1] and I suppose the memorable name helps. But I admit having opened Calendrical Calculations[2] once or twice as well, so perhaps my idea of fun is skewed.

[1] https://en.wikipedia.org/wiki/Doomsday_rule

[2] https://en.wikipedia.org/wiki/Calendrical_Calculations


latexr below makes a good point why:

> without breaking conversation I can figure out what day of the week it’ll be

Being able to maintain the flow of a conversation because you are able to do things in your head is incredibly useful social skill.

It's like when you are talking at dinner with friends: the conversation goes back and forth and sideways, but as soon as someone pulls ouf a phone, the conversational dynamic changes.


I reckon it makes for a pretty neat party trick, I guess


For keeping track of the "key day of the week" from year to year: as you move forward through the years, it advances by one when you move into a non-leap-year, and advances by 2 when you move into a leap year. This year (2026) those days are all Saturdays. Next year, 2027, they will all be Sundays. And in 2028 those days will all be Tuesdays. (If 2028 were not a leap year than they would be Mondays, but since 2028-04-04 is 366 days away from 2027-04-04 due to 2028-02-29 being added in, that's two more than the nearest multiple of 7 (364) and therefore the "key day" advances by 2).

As I said, I don't have a good mnemonic worked out yet for remembering which "key day of the week" goes with which year. But the human mind remembers trauma, and I will probably never forget that September 11, 2001 was a Tuesday. (I clearly remember arriving at work and being asked "Did you hear about the plane crashes?" — both had happened during my 30-minute walk to the office). Which gives me a fixed point I can always calculate from: September 4th, 2001 was a Tuesday, so September 5th was a Wednesday. That means 2001's key day of the week was a Wednesday, and then I can work forward from there: 2002 = Thu, 2003 Fri, 2004 Sun. Then I can add five days for every four years: 2008 Fri, 2012 Wed, 2016 Mon, 2020 Sat, 2024 Thu. Then 2025 Fri, 2026 Sat, and I'm back to current year.

That's not a great mnemomic, because it takes me quite a while to work back up to the current year from 2001. If anyone can think of a better mnemonic, please let me know.


https://en.wikipedia.org/wiki/Doomsday_rule

Basically the following days have the same day of the week: Jan 3 or 4 on a leap year, last day of February, all the even pairs day / month days after that (4/4, 6/6, 8/8, 10/10, 12/12), 7/11 and 11/7, 9/5 and 5/9.


Amazing mnemonics, thank you for sharing. Do you practice this as a mental exercise, or do you actually need to know the day of the week for a specific date that often?


Not that often, maybe one every couple of months. Usually when someone asks me "are you available at (time) on the 31st?" they actually expect me to pull out my phone and load the calendar app. But it's nice to be able to think "Hmmm, that's a Monday, I have that 9:30 AM meeting every Monday" and inform them "I can't do 10:00, how about 11:00?" without having to pull out my phone. (Then I pull out my phone to confirm that 11:00 AM works).

Where I have used it more often is when I am wondering "what day of the week will Christmas be this year?" or "what day of the week will my birthday fall on this year?". It's nice to be able to work those out mentally without pulling up a calendar app and tapping "next month" multiple times. But even that is a rare occurrence.


For figuring the doomsday of a particular year, you can use the Odd+11 rule.

Let X be the last two digits of a year.

If X is odd, add 11.

Divide X by 2.

If X is odd, add 11.

Let Y = 7 − (X mod 7).

Count forward Y days from that century's anchor day to get the year's doomsday.

https://arxiv.org/pdf/1010.0765


Wow, this is fantastic! That's what I expected from the original article! Instead it "merely" presented a quick signed-mod-7 trick for 32- and 64-bit architectures. Interesting, but given day/month/year is what I actually face and your trick here is exactly what I was looking for! Thanks so much, I'll use this the rest of my life!


> ... have to remember that it's one day less in non-leap-years ...

How about just remember January 2nd but for the following year as key days. i.e. if you consider January and February 2027 to be part of 2026's "key days year", then you can forget about whether it's a leap year or not (though you still have to calculate what the key day is from year to year).

[Aside - it would be simpler if the leap day were the 32/Dec instead of 29/Feb!]

Noting also that Jan & Feb (of next year) are the same as May & June (of this year), so you get 2/Jan/Y+1 and 6/Feb/Y+1.


> Aside - it would be simpler if the leap day were the 32/Dec instead of 29/Feb!

Well, February did use to be the last month of the year. (And whoever messed it up did, in fact, get stabbed.)



Did not know it was called that; thanks for the link. And invented by John Conway (drawing on work by Charles Dodgson a.k.a. Lewis Carroll), no less? Man, the guy was a genius, wasn't he.


Thanks for sharing that.

I have a mobile-friendly web-app where you can practice this technique, just click the link in the page's nav: "Weekle - Weekday Guessing Game"


“All of that is math you can easily do in your head in seconds.”

It takes me way too long and I still have to use my fingers nowadays


Some examples are easier than others, like the mentioned 12/25. 12/12 is Saturday -> 25-12 is 13 more days -> same day as 1 before 12/12 -> Friday.


I don't know what's wrong with me, but I can't do mental calculations with dates because I always think I'm off-by-one, no matter what.

I prefer to "move vertically" in the month. Knowing that 1=8=15=22=29, using prlin's example for December 25 (sibling comment), I'd go like:

"12 is Saturday, 15 is Tuesday, 22 is also Tuesday, so 25 is Friday."

So, starting from key date (12), moving to "the 1 column" (15), moving up or down to the closest/easiest date (22), and then finishing from there.

Slower for sure, but easier for me to not lose track. And now having a known day in every month thanks to rmunn's mnemonic, is going to be a huge help.


Just to clarify, I didn't invent this. I don't think you were attributing it to me when you said "rmunn's mnemonic", I think you meant "the mnemonic that rmunn posted". But just in case anyone thinks I invented this, I didn't. I don't remember where I got it from, it was twenty-plus years ago that I learned this mnemonic, but I didn't invent it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: