A "Friday the Thirteenths" Solution

Monday, June 9, 2008

There was a recent post on LessThanDot to create a small application to find all the “Friday the 13th’s” occuring in a range of dates.  Here is my simple solution to the challenge.  I also made it flexible enought to find any occurrence of a day / day of week combination within that range.  It runs surprisingly quick even when looking over the next 500 years.

Also, if you like my color scheme, I’ve made it available for download here.


  1. http:// says:

    Wouldn’t it be a lot faster to set the start date to the first 13th (or whatever) of the month, then increment by a month each time?

  2. MikeBosch says:

    Great observation. This would almost certainly improve performance, although the performance isn’t necessairly suffering now. We would just have to add some extra logic to deal with the fact that not every month has a certain day; also, even if they do it might not on a certain year thanks to leap years. I’ll write some tests and refine it.

Leave a Reply