How to Use the TIMEVALUE function to convert text to time
In this example, a text string has to be converted to a valid time. Columns A and C contain different start and end times as part of a standardized text string. It is possible to extract the times and convert them to valid time values that can be used as the basis for calculations. To convert text into a valid time, use the TIMEVALUE function. This function returns the decimal number of the time represented by a text string. The decimal number is a value ranging from 0 to 0.99999999, representing the time from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).
To extract and convert text to time:
- Select cells B2:B10 and type the following formula: =TIMEVALUE(MID(A2,8,5)).
- Press Ctrl+Enter.
- Select cells D2:D10 and type the following formula: =TIMEVALUE(MID(C2,6,5)).
- Press Ctrl+Enter.
- Select cells B2:B10 and D2:D10.
- From the Format menu, select Cells.
- Select the Number tab, click Time under Category, then select the 1:30:55 PM option in the Type box.
- Click OK.
This tip is compatible with Excel 97, 2000, 2003 and 2007.
- How to use the TEXT function to extract parts of a date in Excel
- Using the UPPER function to change text from lower - uppercase
- How to use the DOLLAR function to convert number to currency
- Use the LEFT, MID, and RIGHT functions to extract date parts
- How to Use the FIXED function to round and convert numbers
