Understanding Dates and Times in VBScript - The Significance of 30 Dec 1899
(Page 3 of 4 )
Okay, so back to the question at hand. Why 30 Dec 1899. Why not 1 Jan, 1900 to make calculations easier? And what happened to 31 Dec 1899? It makes no sense. Or does it?
The idea was originally to simplify calculations by using the beginning of the century as a zero point on the time line. This would have been midnight on 31 Dec 1899, thus the very first second that elapsed would have been on 1 Jan 1900, making it the very first second of the century, also making 1 Jan 1900 the first full day. This seems like a very logical solution. Unfortunately, human logic and computer logic aren’t always the same.
The date functions in VBScript (and originally Visual Basic) were largely taken from Microsoft Excel which already had a large set of built-in date functions. Why reinvent the wheel?
There’s just one small problem. If you examine the Excel functions that were used, you’ll run into a slight glitch. January 1, 1900 is considered 1, the first full day. The functions also show that February 28, 1900 is equal to 59. And it’s true that 59 days had elapsed. Great. If you tried March 1, 1900 as a date it would return 61. Uh-oh.
What happened to 60? February 29, 1900? There’s one minor problem—the year 1900 was not a leap year. How could the Excel guys have missed that? The truth is that they didn’t. It was an imported bug. Literally!
Excel was written with support for importing from Lotus 123, which displayed this bug. In order to support imported dates, Excel needed to calculate them the same way. The truth is that this was probably an intended bug in Lotus. It had memory constraints, so it uses a simplified method of determining whether or not a particular year was a leap year. The Lotus team probably wasn’t too worried about being wrong about the first two months of a year so long ago.
The VB team was; so rather than starting from January 1, 1900, they elected to make calculations from the previous year by moving the epoch back one day to December 31, 1899 instead. Thus the starting point for time became midnight of December 30, 1899.
Next: Using the VT_Time Specification >>
More Windows Scripting Articles
More By Nilpo