Combine Date and Time Columns in Excel with a Formula or VBA
Question details
Combine dates and times from separate Excel columns into timestamps formatted as yyyy-mm-dd hh:mm:ss.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet has dates and times in separate columns, and each row needs a combined timestamp.
- Observed behavior
- The desired output is one date-and-time value per row, displayed with seconds.
Check that the date and time cells contain numeric Excel date and time values rather than text. Confirm that the time cells do not include an unwanted date component.
Add the date and time cells with a formula
Use this method to combine values in a worksheet without a macro.
Excel stores dates and times as serial numbers, so adding a date value to a time value produces a combined timestamp.
If the date is in A2 and the time is in B2, select C2 and enter =A2+B2.
Drag the fill handle from C2 down through the rows containing dates and times.
Select the output cells, open Format Cells, choose Number > Custom, and enter yyyy-mm-dd hh:mm:ss in the Type box.

Combine selected date and time ranges with VBA
Use a macro when you want to select the input ranges and write the combined values to an output column.
Combine date and time columns in WPS Spreadsheet
Use a simple addition formula and a custom number format in WPS Spreadsheet to create one timestamp per row.
- 1. Open the worksheet: Open your workbook in WPS Spreadsheet and locate the date and time columns.
- 2. Add the values: In an empty output cell such as C2, enter =A2+B2, adjusting the references to match your worksheet.
- 3. Fill the formula: Drag the fill handle down the output column to combine the remaining rows.
- 4. Format the results: Select the output cells, open Format Cells, choose Custom, and enter yyyy-mm-dd hh:mm:ss.

Frequently Asked Questions
Why does the combined result appear as a number?
Excel stores dates and times as serial numbers. Select the result cells, open Format Cells > Number > Custom, and apply yyyy-mm-dd hh:mm:ss.
What if the formula returns a value error?
Check whether the source cells contain text instead of numeric dates or times. Convert text dates or times to Excel values before using =A2+B2.
Can I combine a whole column without VBA?
Yes. Enter =A2+B2 in the first output cell, then drag its fill handle down to apply the formula to the other rows.
What happens if a time cell also contains a date?
Adding the full time-cell value also adds its date portion. If you only need its time of day, use =A2+MOD(B2,1), then apply the custom timestamp format.




