pagila=# select extract(dow from mydate), to_char(mydate, 'DAY'), count(*) from
pagila=# (select ('2000-01-01'::date + x * '1 day'::interval) as mydate from (select generate_series as x from
pagila=# generate_series(0,365*400))x ) y where extract(day from mydate) = 13 group by extract(dow from mydate),
pagila=# to_char(mydate, 'DAY') order by 1;
date_part | to_char | count
-----------+-----------+-------
0 | SUNDAY | 687
1 | MONDAY | 684
2 | TUESDAY | 685
3 | WEDNESDAY | 686
4 | THURSDAY | 684
5 | FRIDAY | 688
6 | SATURDAY | 683
(7 rows)
Time: 769.227 ms
Superstition Suspicion
So, today was [http://urbanlegends.about.com/cs/historical/a/friday_the_13th.htm Friday the 13th], which is a day that tends to strike fear in the hearts of many people. Personally I am not a very superstitious person, but I also don’t spit in the eye of fate if I don’t have to. In any case, AndrewSN made an interesting comment on IRC today how the 13th more often falls on Friday than any other day of the week. A quick glance at this years calender did not bear that out, but AndrewSN is generally right about a lot of things so I thought a little SQL experiment was in order. Basically all I needed to do was select all of the “13th days” for each month, and then count them based on which day of the week they were. To get a fair comparison, I did it over a range of [http://www.merlyn.demon.co.uk/moredate.htm#GC 400 years], and started in [http://www.ozdoba.net/swisswatch/year2000.html the year 2000].
Sure enough, Friday comes out way ahead. One has to wonder if this is part of the reason for the success of this superstition, had they picked another date, maybe the lower frequency would have been an issue [[image /xzilla/templates/default/img/emoticons/smile.png alt=”:-)” style=”display: inline; vertical-align: bottom;” class=”emoticon” /]] It makes me wonder if that other superstition really is true as well… you know, were they say if you think Friday the 13th is scary, wait until you see [http://www.imdb.com/title/tt0083033/ Saturday the 14th].