Home
> Business Databases > Convert CRSP date YYYYMMDD to Excel true date
Convert CRSP date YYYYMMDD to Excel true date
If you have a data file from CRSP (or many other sources), the date may be recorded as a text string of the form YYYYMMDD (for example, 20151231 for the last New Year’s Eve). If you wish for Excel to interpret this as a date, for the purpose of analysis, this can be done with the four formulae below.
=DATE(LEFT(A2,4), MID(A2,5,2), RIGHT(A2,2))
This reads the following fields.
- Year from the first 4 characters of cell A2.
- Month from the middle 2 characters of cell A2 starting from position 5.
- Day from the last 2 characters of cell A2.
See the image below for an example.
Now that the dates are recorded this way, Excel can interpret them correctly when doing analysis or when using features like pivot tables.
Categories: Business Databases
CRSP, Excel
Another potential solution is to use the “Text to Columns” (ALT+A+E) function and selecting appropriate Date format on step 3.