Excel Formula to Classify Comma-Separated Dates as Day or Week
Question details
The user needs an Excel formula to evaluate a cell containing comma-separated dates and categorize the output as "Day" if there are 1 to 3 dates, and "Week" if there are more than 3 dates.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Evaluating a single cell that contains multiple dates formatted as a single text string with comma separators.
- Observed behavior
- The goal is to dynamically display "Day" when the text string contains 0 to 2 commas (representing 1 to 3 dates), and "Week" when it contains 3 or more commas (representing 4 or more dates).
Ensure that the dates within your target cell are consistently separated by a single comma and that there are no accidental trailing commas at the end of the text string.
Use LEN and SUBSTITUTE Functions to Count Commas
This method calculates the number of commas in the text string to determine exactly how many dates are present in the cell.
Entering multiple dates into a single cell causes Excel to format the entry as a text string. Because of this, standard date functions will not work. Instead, you can use text functions to count the number of separators (commas).
If a cell contains one to three dates, it will have zero to two commas. If it contains more than three dates, it will have three or more commas. By counting these commas, the IF function can correctly classify the cell.
Click on the empty cell where you want the "Day" or "Week" classification result to appear.
Type the following formula into the formula bar: =IF(A2="","",IF(LEN(A2)-LEN(SUBSTITUTE(A2,",",""))<=2,"Day","Week")). Change "A2" to match the cell containing your comma-separated dates.
Press Enter to execute the formula. Click the bottom-right corner of the cell and drag the fill handle down to apply this formula to the rest of the column.

Classify and Count Cell Text Instantly with WPS Spreadsheet
WPS Spreadsheet fully supports advanced text manipulation functions like LEN and SUBSTITUTE, allowing you to quickly process complex strings and comma-separated lists. It's a powerful and free tool for all your daily data analysis needs.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the dates.
- 2. Select an Empty Cell: Click on a blank cell adjacent to your comma-separated text string.
- 3. Input the Formula: Type =IF(A2="","",IF(LEN(A2)-LEN(SUBSTITUTE(A2,",",""))<=2,"Day","Week")) into the formula bar.
- 4. Get Your Result: Press Enter to instantly classify your cell text as Day or Week based on the date count.

Frequently Asked Questions
How exactly does the LEN and SUBSTITUTE formula count commas?
The LEN(A2) function returns the total character count of the cell. The SUBSTITUTE(A2,",","") function creates a temporary version of the text with all commas removed. Subtracting the length of the string without commas from the original length gives you the exact number of commas present in the cell.
What happens if the cell contains only one date without any commas?
If the cell contains a single date, there are zero commas. The formula LEN(A2)-LEN(SUBSTITUTE(A2,",","")) will result in 0. Since 0 is less than or equal to 2, the IF statement will correctly output "Day".
How do I adjust the formula if my dates are separated by a comma and a space?
The core logic still works perfectly because the formula only searches for the comma character. However, if you specifically need to count a comma followed by a space, you can modify the substitute portion to SUBSTITUTE(A2,", ","") and adjust the mathematical comparison if needed.
Will this formula work if my dates are formatted as actual date values instead of text?
No. Excel cannot store multiple distinct numeric date values in a single cell natively. Once you enter multiple dates separated by commas into one cell, Excel automatically treats the entire entry as a single text string, which is why text-based functions are required to evaluate it.




