Transferring dates between Excel files (inaccurate

2019-01-20 17:30发布

问题:

I have the following formula that I use regularly to copy information from one file to another. Essentially, it takes a given id (A2) and searches for it's match in the second spreadsheet, then copies the data from the column specified in the first part of the formula (in this case, C).

=INDEX([spreadsheet.xlsx]Sheet1!$C$2:$C$50000,MATCH(A2,[spreadsheet.xlsx]Sheet1!$B$2:$B$50000,0))

The formula works perfectly on all columns except when I try to transfer dates. It ALWAYS transfers a date exactly 4 years and 1 day greater than the actual date. I haven't always had this issue transferring dates, but I have no idea what could be causing this.

Any thoughts?

回答1:

Slight abbreviation from Microsoft:


Excel supports two different date systems:

The 1900 Date System
In the 1900 date system, the first day that is supported is January 1, 1900. When you enter a date, the date is converted into a serial number that represents the number of elapsed days since January 1, 1900. For example, if you enter July 5, 1998, Excel converts the date to the serial number 35981.

By default, Excel for Windows uses the 1900 date system.

The 1904 Date System
In the 1904 date system, the first day that is supported is January 1, 1904. When you enter a date, the date is converted into a serial number that represents the number of elapsed days since January 1, 1904. For example, if you enter July 5, 1998, Excel converts the date to the serial number 34519.

By default, Excel for the Macintosh uses the 1904 date system. Because of the design of early Macintosh computers, dates before January 1, 1904 were not supported. This design was intended to prevent problems related to the fact that 1900 was not a leap year. If you switch to the 1900 date system, Excel for the Macintosh does support dates as early as January 1, 1900.

The Difference Between the Date Systems

Because the two date systems use different starting days, the same date is represented by different serial numbers in each date system. The difference between the two date systems is 1,462 days; that is, the serial number of a date in the 1900 Date System is always 1,462 days bigger than the serial number of the same date in the 1904 date system. 1,462 days is equal to four years and one day (including one 'leap' day).

Setting the Date System for a Workbook
In Excel, each workbook can have its own date system setting, even if multiple workbooks are open.

To set the date system for a workbook in Microsoft Office Excel 2007, follow these steps:
1. Open or switch to the workbook
2. Click the Microsoft Office Button, and then click Excel Options
3. Click Advanced
4. Click to select the Use 1904 data system check box under the When calculating this workbook, and then click OK

Notice that if you change the date system for a workbook that already contains dates, the dates shift by four years and one day.

Problems Linking and Copying Dates Between Workbooks
If two workbooks use different date systems, you may encounter problems when you link or copy dates between workbooks. Specifically, the dates may be shifted by four years and one day.