Compare Birth Years from Excel Dates and Text Values
Question details
Compare the year in an Excel date with the first four characters of a text or numeric value.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- One column contains birth dates, and another contains values that begin with a four-digit birth year.
- Observed behavior
- Matching years should return a blank result, while different years should be marked with D.
Check that column A contains real Excel dates and that the first four characters in column B are the birth year. Place the formula in an empty column so it does not overwrite your data.
Compare birth years with a formula in each row
Use this formula in most Excel versions and fill it down for all rows.
In an empty cell such as C1, enter =IF(YEAR(A1)=VALUE(LEFT(B1,4)),"","D"). Adjust A1 and B1 if your first data row uses different cells.
Select C1 and drag its fill handle down alongside the remaining rows, or double-click the fill handle.
Look down column C: D identifies a different year, while a blank result means the years match.

Compare multiple rows with a spilled MAP formula
Use a single formula when your Excel version supports MAP and LAMBDA.
Flag different birth years in WPS Spreadsheets
Use YEAR, LEFT, and VALUE in WPS Spreadsheets to compare a date with a value beginning with a four-digit year, then fill the formula down.
- 1. Open your workbook: Open WPS Spreadsheets and select Open to choose your Excel workbook.
- 2. Enter the formula: In an empty cell such as C1, enter =IF(YEAR(A1)=VALUE(LEFT(B1,4)),"","D"). Adjust the cell references for your data.
- 3. Fill and review: Drag the fill handle from C1 down through your data and check column C for D markers.
- 4. Save the workbook: Select Menu > Save or Save As to save the results in your chosen workbook format.

Frequently Asked Questions
Why does the formula return D?
D means the year extracted from the date in column A differs from the number formed by the first four characters in column B.
Why am I getting a formula error?
Check that the cell in column A contains a valid Excel date and that the first four characters in column B can be converted to a number. Correct the source cells and recalculate.
Can the value in column B be a number instead of text?
Yes. LEFT can read the first four characters of a numeric value, and VALUE converts those characters to a number for comparison. Check that the displayed value begins with the intended four-digit year.
Why does the MAP formula show a spill error?
Clear any occupied cells in the intended spill range below the formula. Also check that both input ranges cover the same number of rows.




