Link to home
Start Free TrialLog in
Avatar of brothertruffle880
brothertruffle880Flag for United States of America

asked on

Excel 2010 - Date arithmetic BEFORE 1900 (1774 up to 1900)

Hi:
I need to compute the number of days/months/years on a group of dates from 1700 to 1900.  I've got about 100 dates I need to compute durations on.
How can I do this?
Example:  October 7, 1779 to January 13, 1800
How many days/months/years.
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try adding 400 years to all dates with a formula like this

=VALUE(SUBSTITUTE(A1,RIGHT(A1,4),RIGHT(A1,4)+400))

and then you can get the date difference.
I created a few UDFs which you can test on the attached workbook. They require that the dates are entered as Text on the worksheet. You can either format the cells as Text or precede your entries with an apostrophe which has the same effect. If you wish to install the functions in your workbook I suggest that you drag the entire module 'DateMan' to your own project and then save your file in XLSM format.
You can change the sequence of year, month and day to your liking. Just change the sequence of the Nds enumerations to match what you enter in the cells you want evaluated. You can also change the Date separator, just below the enum just mentioned, before the actual code starts.
There are samples of how to call the functions on the worksheet.
These are the functions available:-
YEARDIFF, MONTHDIFF, DAYDIFF - These functions were created to allow you to calculate the years, months and days between two dates. They will work on modern days as well as on historical ones. Note that the MONTHDIFF can be used to count the entire difference in months. Please observe how it is deployed in the worksheet.
DATESERIAL / HDATESERIAL - The former is designed as a UDF to call the latter which is designed as VBA function. The HDATESERIAL gives a number to each day since January 1, 0000, also converting dates entered as Text. This would enable you to sort your entries by date.
Finally, there is HWEEKDAY which works very much like VBA's own WEEKDAY function, largely because it utilizes that function. If Sunday is the first day of the week (the WEEKDAY function allows you to select your first day of the week), Monday would be the second. Hence, the result you see in the worksheet confirms that Charlemagne was crowned on a Tuesday, on Christmas Day in the year 800. Perhaps this function will be useful to you in some way.
EXX-130602-Dates-from-0000.xlsm
Faustulus,

I have not checked all of your UDFs, but your HDATESERIAL function has a logical flaw in how it handles leap years.

Specifically, a year ending in "00" is only a leap year if it is divisible by 400.  Your code has it backward: your code makes the years divisible by 400 a standard year, and the "00" years that are not evenly divisible by 400 leap years.  (Of course, Excel treats 1900 as a leap year--incorrectly--while VBA does not.)

Also, keep in mind that when the Gregorian calendar was adopted, there was a 10-day skip: 1582-10-04 was immediately followed by 1582-10-15.  Your UDF makes no adjustment for that, so any date calculation that spans that adjustment will be off by 10 days.

:)

Patrick
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial