How to use the TIMEVALUE function
What is the TIMEVALUE function?
The TIMEVALUE function returns a decimal number representing an Excel time value, based on a text string. Excel uses decimal numbers between 0 and 0.99988426 formatted as time. 0 (zero) is 12:00:00 AM and 0.99988426 is 11:59:59 P.M.
The TIMEVALUE function in Excel is rarely needed to convert values in formulas. Excel automatically handles conversion of numbers, text, logical values, and error values as required. TIMEVALUE function is provided for compatibility with other spreadsheet applications. In most cases, Excel will format values correctly without requiring the TIMEVALUE function function.
Only use TIMEVALUE function if you find Excel is not properly converting a value to text in a specific formula. In general, you can avoid using it entirely since Excel auto-converts types seamlessly in most situations.
1. Introduction
What is an Excel time value?
Excel time is actually a decimal number ranging between 0 and 1 in Excel and then formatted as time.
For example, 12:00 PM is represented as 0.5 because it is half of a day, you can verify this by typing 12:00 PM in a cell and then change the cell formatting to general. This will show the value as Excel interprets it.
Does the TIMEVALUE function ignore dates?
Yes, the TIMEVALUE function ignores the date part , example "22-Aug-2019 6:35 PM" returns 0.774305556 which is equal to "6:35 PM".
How does Excel recognize time values?
Excel recognizes certain text strings like "6:45 PM" as valid time values. A recognized time value is right aligned in the cell just like a regular number, shown in the image below in cell B2.
A time number that is not recognized is left aligned which is demonstrated in cell B4 in the image above. This visual feedback lets you easily spot values that need closer inspection.
How to show the decimal value as an Excel time value?
- Select the cell containing the decimal value.
- Press CTRL + 1 to open the "Format Cells" dialog box shown in the image above.
- Select category "Time".
- Select a type.
- Press with left mouse button on the "OK" button.
Why convert time values to decimal numbers?
The conversion allows you to perform arithmetic operations to time values, this works only if the time value is represented as a numerical value.
This lets you add or subtract, for instance, hours, minutes, and seconds easily using simple Excel formulas. It also lets you perform average, median, and other calculations using specific Excel functions.
2. Syntax
TIMEVALUE(time_text)
time_text | Required. A text string within quotation marks that represent time, for example "03:23 PM" or "22:21". |
3. Example 1
The image above demonstrates the TIMEVALUE function in cells B3 to B8, column C describes the formula in grey text.
The first value demonstrated in cell B3 is 0.075, which is the result of TIMEVALUE("1:48 AM"). The TIMEVALUE function converts the time string "1:48 AM" to a decimal number representing the fraction of a 24-hour day. 1:48 AM is 1.8 hours after midnight, which is 1.8/24 = 0.075 of a day.
Formula in cell B3:
The second value demonstrated in cell B4 is 0.757638889, which is the result of TIMEVALUE("6:11 PM"). The TIMEVALUE function converts the time string "6:11 PM" to a decimal number. 6:11 PM is 18.183333 hours after midnight, which is 18.183333/24 ≈ 0.757638889 of a day.
The third value demonstrated in cell B5 is 0.415277778, which is the result of TIMEVALUE("9:58 AM"). The TIMEVALUE function converts the time string "9:58 AM" to a decimal number. 9:58 AM is 9.966667 hours after midnight, which is 9.966667/24 ≈ 0.415277778 of a day.
The fourth value demonstrated in cell B6 is 0.999988426, which is the result of TIMEVALUE("11:59:59 PM"). The TIMEVALUE function converts the time string "11:59:59 PM" to a decimal number. 11:59:59 PM is 23.99972 hours after midnight, which is 23.99972/24 ≈ 0.999988426 of a day.
The fifth value demonstrated in cell B7 is 0, which is the result of TIMEVALUE("0:00 AM"). The TIMEVALUE function converts the time string "0:00 AM" (midnight) to a decimal number. Midnight represents the start of the day, so it's 0/24 = 0 of a day.
The sixth value demonstrated in cell B8 is 0.5, which is the result of TIMEVALUE("12:00 PM"). The TIMEVALUE function converts the time string "12:00 PM" (noon) to a decimal number. Noon is exactly halfway through the day, so it's 12/24 = 0.5 of a day.
The decimal numbers shown in cells B3 to B8 are the actual Excel time representation of:
- 1:48 AM
- 6:11 PM
- 9:58 AM
- 11:59:59 PM
- 0:00 AM
- 12:00 PM
4. Example 2
This example demonstrates the FILTER and TEXTSPLIT functions work together to extract the time from the text, and then TIMEVALUE converts it to a decimal fraction that represents a time value in Excel.
Formula in cell D3:
The first value demonstrated in cell D3 is 0.458333333, which is the result of extracting and converting "11:00 PM" from the text in B3. The TIMEVALUE function converts this time to a decimal representing the fraction of a day. 11:00 PM is 23 hours after midnight, which is 23/24 ≈ 0.458333333 of a day.
The second value demonstrated in cell D4 is 0.102083333, which is the result of extracting and converting "2:27 PM" from the text in B4. The TIMEVALUE function converts this time to a decimal. 2:27 PM is 14.45 hours after midnight, which is 14.45/24 ≈ 0.102083333 of a day.
The third value demonstrated in cell D5 is 0.290277778, which is the result of extracting and converting "6:58 AM" from the text in B5. The TIMEVALUE function converts this time to a decimal. 6:58 AM is 6.966667 hours after midnight, which is 6.966667/24 ≈ 0.290277778 of a day.
The fourth value demonstrated in cell D6 is 0.538194444, which is the result of extracting and converting "12:55 PM" from the text in B6. The TIMEVALUE function converts this time to a decimal. 12:55 PM is 12.916667 hours after midnight, which is 12.916667/24 ≈ 0.538194444 of a day.
The fifth value demonstrated in cell D7 is 0.415277778, which is the result of extracting and converting "9:58 AM" from the text in B7. The TIMEVALUE function converts this time to a decimal. 9:58 AM is 9.966667 hours after midnight, which is 9.966667/24 ≈ 0.415277778 of a day.
Here is an explanation of the formula step by step:
- TEXTSPLIT(B3, " "): This function splits the contents of cell B3 into an array, using the space character (" ") as the delimiter.
The result of this function is an array of mostly text values and one time value. - TIMEVALUE(TEXTSPLIT(B3, " ")): This part of the formula applies the TIMEVALUE function to each element of the array created by TEXTSPLIT.
The TIMEVALUE function converts the time portion of the cell's contents into a valid time value. If the element is not a valid time, the TIMEVALUE function will return an error. - ISNUMBER(TIMEVALUE(TEXTSPLIT(B3, " "))): This part of the formula checks if the TIMEVALUE function was able to successfully convert the time portion of the cell's contents into a valid time value.
The ISNUMBER function returns TRUE if the result of TIMEVALUE is a valid number (i.e., a time value), and FALSE otherwise. - FILTER(TIMEVALUE(TEXTSPLIT(B3, " ")), ISNUMBER(TIMEVALUE(TEXTSPLIT(B3, " ")))): The FILTER function takes two arguments: the array of time values (from the TIMEVALUE function) and the array of boolean values (from the ISNUMBER function).
The FILTER function then returns only the time values that correspond to the TRUE values in the second argument, effectively filtering out any invalid time values.
'TIMEVALUE' function examples
The following article has a formula that contains the TIMEVALUE function.
Functions in 'Date and Time' category
The TIMEVALUE function function is one of 22 functions in the 'Date and Time' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form