Forum Discussion
How to standardize different time formats
To standardize the different date formats in Excel, you can use a combination of text manipulation functions such as TEXT, DATEVALUE, and LEFT, along with some logic to handle the different formats.
Assuming your dates are in column A, you can use the following formula in another column (let's say column B) to convert the dates to a standardized format (mm/yyyy):
=IF(ISNUMBER(DATEVALUE(A1)), TEXT(DATEVALUE(A1), "mm/yyyy"), IF(ISNUMBER(DATEVALUE(LEFT(A1, FIND("/", A1)-1 & "/" & MID(A1, FIND("/", A1)+1, FIND("/", A1, FIND("/", A1)+1)-FIND("/", A1)-1) & "/" & RIGHT(A1, LEN(A1)-FIND("/", A1, FIND("/", A1)+1))), "mm/yyyy"), TEXT(DATEVALUE(LEFT(A1, FIND("/", A1)-1 & "/" & MID(A1, FIND("/", A1)+1, FIND("/", A1, FIND("/", A1)+1)-FIND("/", A1)-1) & "/" & RIGHT(A1, LEN(A1)-FIND("/", A1, FIND("/", A1)+1))), "mm/yyyy"), TEXT(DATEVALUE(MID(A1, FIND("/", A1)+1, FIND("/", A1, FIND("/", A1)+1)-FIND("/", A1)-1) & "/" & LEFT(A1, FIND("/", A1)-1 & "/" & RIGHT(A1, LEN(A1)-FIND("/", A1, FIND("/", A1)+1))), "mm/yyyy")))
This formula checks for three conditions:
- If the value in cell A1 is already a valid date (using DATEVALUE), it converts it to the desired format using TEXT.
- If the date is in the format "dd/mm/yy", it rearranges the parts of the date and converts it to "mm/yyyy".
- If the date is in the format "mm/dd/yy" (with or without time), it rearranges the parts of the date and converts it to "mm/yyyy".
This formula should help standardize the different date formats in your Excel sheet, allowing you to perform calculations accurately in Power BI or any other analysis tool. You can drag this formula down to apply it to the entire column if needed. The text was created with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.