views:

137

answers:

3

I need to store dates in SharePoint that need to go back around 5000 BC. Ideally, I would like to be able to do date addition/subtraction, like this:

oldDate = '5000 BC';
newDate = '1995 AD';
DateDiff(oldDate, newDate, 'Years'); // equals 6995

How should I proceed? Build an old_date class based on strings? Just use regular dates, but add an AD or BC that makes the date negative?

+5  A: 

This is a seriously non-trivial problem, and really depends on what exactly you want to do with those dates. For example, we've only used the current (Gregorian) calendar since 1582. Before that it was the Julian calendar, and before that an old Roman calendar. To make matters worse, this info is really only for Western Europe (and culturally-related areas). So if you are hoping to have someting that will give you proper accepted dates for historical events with a little simple math, you are in for a big dissappointment.

If you just want to carry the Gregorian calendar backwards, I suppose that's doable. However, there still is error, and on that scale it matters. From Wikipedia:

On timescales of thousands of years, the Gregorian calendar falls behind the seasons because the slowing down of the Earth's rotation makes each day slightly longer over time (see tidal acceleration and leap second) while the year maintains a more uniform duration

T.E.D.
+2  A: 

If you are interested only in years and not in days then you could build a custom field with custom editor and store the year value as integer value.

Values less than zero mean BC and values higher or equal that zero mean AD.

eXXL
A: 

I ended up storing dates as a text field in ISO 8601 format:
YYYY-MM-DDThh:mm:ss.sTZD

You don't have to store the entire string, for instance if you wanted to store 5000 BC, you would enter -5000-01-01. I don't get my date addition and subtraction very easily, but it was much easier to get the data in there in the format I wanted.

Nathan DeWitt