How to Convert Relative Text (Like 3 Years Ago) to an Excel Date
Question details
The user needs to translate relative date descriptions stored as text (e.g., 'a year ago', 'three months ago', 'two weeks ago') into actual date values formatted as mm/yy.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Standardizing raw data or survey logs where respondents or systems inputted time relatively instead of using absolute calendar dates.
- Observed behavior
- The data is currently formatted as unstructured text strings, preventing proper chronological sorting or timeline-based mathematical calculations.
Ensure your relative date text follows a predictable structure, usually containing a number or article (like '3' or 'a') followed by a time unit ('weeks', 'months', 'years') so that extraction formulas can accurately parse the values.
Use LET and EDATE Formula for Dynamic Text Extraction
This advanced formula dynamically searches for the time unit keyword within your text and subtracts the exact amount of weeks, months, or years from today's date.
By combining the LET function with SEARCH and EDATE, you can evaluate the entire string in one clean formula. The formula calculates the numeric offset and applies it directly to the current date.
Click on an empty cell next to your relative text string (for example, if your text is in A1, click B1).
Type the following formula: =LET(period,SUM(ISNUMBER(SEARCH({"week","month","year"},A1))*{0,-1,-12}), amount,IFERROR(--LEFT(A1,FIND(" ",A1)-1),1), IF(period=0,TODAY()-7*amount,EDATE(TODAY(),amount*period))) and press Enter. This will output a numerical date serial number.
Right-click the cell and select 'Format Cells'. Go to the 'Number' tab, choose 'Custom' from the category list, type 'mm/yy' in the Type box, and click OK.
Use Nested IFs with TEXTBEFORE and TEXTAFTER
If you are dealing with a limited set of specific phrases, you can map out exact conditions using nested IF functions to translate them.
Easily Handle Complex Formulas with WPS Spreadsheet
WPS Spreadsheet fully supports advanced array functions like LET, EDATE, and SEARCH, allowing you to clean and transform complex text strings into actionable dates effortlessly. The intuitive interface helps you spot formula errors quickly.
- 1. Open your data in WPS Spreadsheet: Launch WPS Office, open the Spreadsheet module, and load the file containing your relative date texts.
- 2. Paste the formula: Click into an adjacent cell and paste the dynamic LET formula provided in the solution.
- 3. Format seamlessly: Use the shortcut Ctrl+1 to open the Format Cells dialog, select Custom, and apply your desired 'mm/yy' format.

Frequently Asked Questions
Can I format the output to show the full date instead of just month and year?
Yes. If you used the LET formula, simply right-click the cell, open 'Format Cells', choose the 'Date' category, and select a full date format (like 'dd/mm/yyyy') instead of 'mm/yy'.
Why does my formula return a #NAME? error?
A #NAME? error usually means your spreadsheet version does not support one of the functions used, such as LET, TEXTBEFORE, or TEXTAFTER. Updating to a newer version of WPS Office or Excel 365 will resolve this.
How do I modify the formula to account for 'days ago'?
To include days in the LET formula, add 'day' to the SEARCH array and corresponding offset: SEARCH({"day","week","month","year"},A1) and match it with offsets {0,0,-1,-12}. In the IF condition, calculate the day subtraction directly from TODAY().
Does the formula automatically adjust to the current date?
Yes. Because both formulas utilize the TODAY() function, the calculation will always be relative to the exact date you open or refresh the spreadsheet.




