For a fun little programming project, I agreed to create a simple genealogy program to hold data from a family history document my mother has that dates back to the mid-1700s. I decided to build it because I could use it as a sort of "testbed" to experiment with different web development programming technologies, primarily Angular and Bootstrap.

So I've been working on it here and there and was doing a little testing of something I'd written when I ran into this error: "The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value". Hmmm. That seemed odd, but I was testing my add page with a date in the year 1732. Well, it turns out that SQL Server doesn't allow DateTime values earlier than 1/1/1753. That just begs the question as to why. The answer is simple: there are 12 days missing from the calendar in 1752. Say what?!?

Here's the story
The Julian Calendar was instituted by Julius Caesar in 46 B.C. The Julian Calendar was built on the premise that the year was 365.25 days long and consisted of normal 365-day years interspersed with a 366-day leap year every fourth year. In 730 A.D., the Venerable Bede (an Anglo-Saxon monk) announced that the Julian year was 11 minutes, 14 seconds too long, building a cumulative error of about 1 day every 128 years. Nothing was done about this for 800 years.

By 1582, the error had grown to about 10 days. That year, Pope Gregory XIII decreed that Thursday, October 4, 1582 would be followed by Friday, October 15, thus correcting the calendar by 10 days. This began the Gregorian Calendar that is in use today. It uses a four-year cycle of leap years, and eliminates each leap year that occurs on three of every four centesimal years. Only centesimal years that are evenly divisible by 400 are leap years. Thus, the year 1600 was a 366-day leap year, but 1700, 1800, and 1900 were each 365 days. The year 2000 is also a leap year, as will be the year 2400.

The British and its possessions, including the American colonies, did not implement the Gregorian Calendar for another 170 years, by which time 11 days needed to be eliminated. The British decreed that September 2, 1752 would be followed by September 14, 1752.

Because there would be errors trying to calculate dates due to this change, SQL Server was created with a built-in block for dates earlier than 1753.

So my attempt to put a date from 1732 properly resulted in an out-of-range error.  Pretty weird little bit of trivia, right?

Sources

StackOverflow
JustRealized
IBM

 

Category: coding
0