Return the First Day of Each Month by ID in Excel
Question details
Return the beginning of the starting month for each LCID and advance one month for each subsequent record for that ID.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains records grouped by LCID, with a starting date for each group.
- Observed behavior
- The desired output is a sequence of first-of-month dates that restarts for each LCID.
Arrange records so each LCID occupies one contiguous group in the intended record order. For the example below, put LCIDs in column A and a valid starting date in column B of the first row of each group.
Use EDATE to advance the month within each LCID group
Use this formula when records for each LCID are adjacent and the first row of each group contains its starting date.
This example assumes headers are in row 1 and the first record is in row 2. Adjust the column references and starting row to match your worksheet.
In cell C2, enter =DATE(YEAR(B2),MONTH(B2),1) to return the first day of the month containing the starting date.
In cell C3, enter =IF(A3=A2,EDATE(C2,1),DATE(YEAR(B3),MONTH(B3),1)). It advances the previous result by one month when the LCID matches, or starts a new sequence from the date in B3 when it changes.
Drag the fill handle from C3 down through the remaining records. Select column C and use Home > Number Format to choose a date format.

Create the same monthly sequence in WPS Spreadsheets
Use DATE and EDATE in WPS Spreadsheets to calculate the first day of each month for grouped LCID records.
- 1. Open the worksheet: Open your workbook in WPS Spreadsheets and arrange the records so each LCID is contiguous and in the intended order.
- 2. Set up the columns: Place LCIDs in column A and a valid starting date in column B of the first row of each group. Use column C for the results.
- 3. Enter the formulas: With the first record in row 2, enter =DATE(YEAR(B2),MONTH(B2),1) in C2. In C3, enter =IF(A3=A2,EDATE(C2,1),DATE(YEAR(B3),MONTH(B3),1)).
- 4. Fill and format: Drag the fill handle from C3 down to the last record, then select column C and choose a date format from the Home tab.

Frequently Asked Questions
Why does the formula restart for the same LCID?
The formula compares each LCID only with the row above it. If the same LCID appears in a separate group, it starts a new sequence. Arrange each ID's records together in the intended order.
Does every row need a starting date in column B?
No. In the example, only the first row of each LCID group needs a valid starting date in column B. Later rows in that group use the previous result in column C.
Why do the results appear as numbers instead of dates?
Excel stores dates as serial numbers. Select the result cells and choose a date format from Home > Number Format.
What happens when the sequence crosses into a new year?
EDATE automatically advances the year. For example, EDATE applied to December 1 returns January 1 of the following year.




