I have data in the format as d.hh.mm.ss and hh.mm.ss and I need to conver both into a time value of HH.MM.SS
In A1 the text string is 16.21:38:27
in A2 the text string is 04:08:45
My resulting cell should show B1 405:38:27
B2 04:08:45
I have tried using =LEFT(A1,SEARCH(":",A1)-1)+TIMEVALUE(MID(A1,SEARCH(":",A1)+1,255))
but the results are wrong
A1 is shown as 403:29:24
A2 is shown as 104:45:00
I would like one formula for both strings
As 4:08:45 is a valid time format and 16.21:38:27 is not this formula should work for you in both cases:
=IF(ISNUMBER(A1+0),A1+0,RIGHT(A1,8)+LEFT(A1,FIND(".",A1)-1))
format result cells as [h]:mm:ss
Here it is:
= IF(ISERROR(FIND(".",A1)),
TIMEVALUE(A1),
VALUE(LEFT(A1,FIND(".",A1)-1)) + TIMEVALUE(MID(A1, FIND(".", A1)+1, 8)))
If a "." doesn't exist in the string, it simply uses TIMEVALUE() to parse the time. Otherwise, it parses the portion before and after the "." separately. The number of days forms the integer portion of the result, and the time is computed as a fractional day. This is then formatted using the standard formatting dialog into [h]:mm:ss format.
If you want B1 to store a string of the converted hours/minutes/seconds rather than a formatted number, wrap the whole of the above in TEXT(formula above, "[h]:mm:ss").
#TimWilliams hit the nail on the head. You have a typo. Change 16.21:38:27 to 16:21:38:27 and it will work fine. You can additionally wrap your formula to check the length. If it is more than 8 Chars then it means a date is added to it. See this example
Try this (You can use this for both)
=IF(LEN(A1)>8,LEFT(A1,SEARCH(":",A1)-1)+TIMEVALUE(MID(A1,SEARCH(":",A1)+1,255)),TIMEVALUE(A1))
SNAPSHOT
EDIT
I just noticed that you have hardcoded 255 in your formula. You don't need to do that. This will also work.
=IF(LEN(A1)>8,LEFT(A1,SEARCH(":",A1)-1)+TIMEVALUE(MID(A1,SEARCH(":",A1)+1,LEN(A1)-SEARCH(":",A1)+1)),TIMEVALUE(A1))
BTW, to make it foolproof you make also add the TRIM function to the above formula as well...
Related
Example:
I am using the formula:
=IMDIV(F3,0.7)
f3 value = 37.44, so the result on the formula cell = 53.9948890...
I need to turn the 53.9948890... into a dollar value, so I want to show it like $53.99
AT THE END I JUST WANT THE DOLLAR VALUE WITHOUT ANY FORMULAS.
How can I format the results of the formula into dollar value?
I tried to highlight the cells and change the formatting but it DIDN'T WORK.
I tried to copy and paste just the numerical values and then formatting the cells, and it DIDN'T WORK.
If I type the number and then I try formatting the cell, then IT WORKS, but then I need to do it manually for hundreds of lines..
You can use DOLLAR but this returns text again which means you cannot input this into mathematical comparisons/functions as is.
=DOLLAR(IMDIV(F3,0.7))
I would recommend using ROUND instead to convert your output to be numeric and then just format the column as currency. Then you have numeric outputs that you can actually feed into functions or compare
=ROUND(IMDIV(F3,0.7),2)
The real question is why are you using IMDIV in the first place? As you have discovered, that method will require some downstream work to format to number/currency. Since you are just supplying real numbers, you don't really use the 'special sauce' that is added to the IMDIV function. You are just taking extra steps to do a standard division.
i.e. (37.44 + 0i) / (0.7 + 0i) = 37.44/0.7 so why not just use F3/.7?
As you can see in below photo, both outputs return the same number. The only difference is the IMDIV function returns this value as string which has to be converted before later use.
i am trying to convert a number into decimals of a foot in excel. here is my formula
=IF(C2="", "",ROUND(LEFT(C2,FIND("-",C2)-2)+SUBSTITUTE(REPLACE(C2,1,FIND("-",C2),""),CHAR(34),"")/12,4))
If Cell C2 is 41-9, it returns 4.75
it works fine except when excel automatically changes cell c2 to a date such as 8-8. any ideas?
Format C2 as text before you enter the value. Then it won't convert to date.
But your formula will still not work, because it does not handle single digits for the foot measure well. The single digit will result in a blank text result from the Left() function, which causes an error when that blank text is added to the extracted number of the Substitute bit.
Wrap an N() function around the Left(), which will turn a blank result into a zero, and then the formula works (given the cell format is text, not date).
=IF(C2="", "",ROUND(N(LEFT(C2,FIND("-",C2)-2))+SUBSTITUTE(REPLACE(C2,1,FIND("-",C2),""),CHAR(34),"")/12,4))
I have a 12 digit number in column A like so:
Column A
041120121601
Within this number there is a date 201216 or 20/12/16.
I am trying to get the date from the number using mid:
=MID(B8,5,6)
I now get this as a result: 201216.
I am trying to format this as a date like this:
20/12/2016
Here's what i've tried:
=TEXT(D8, "00-00-00")
This gives me this:
20-12-16
This is close, but i need it to be 20/12/16
OK, if it starts with a 0, Excel doesn't think this is a number. It thinks it's text. This is important, because one day someone will copy and paste the input data and Excel will automagically convert them to numbers and your formulas all
will break because the leading 0 is missing now.
So, let's first convert the cell into a number, then back into text with "000000000000" format:
=Text(Value(A1),"000000000000")
Then apply the DateValue formula with three Mid functions as Tim describes.
(Or your input data are numbers in "000000000000" format, but that's a little unusual.)
You can your split MID and force a date separator betwixt each number and wrap it in DATEVALUE, then just format as a date.
=DATEVALUE(MID(B8,5,2)&"/"&MID(B8,7,2)&"/"&MID(B8,9,2))
If it's always the same amount of characters then =MID(TRIM(A1),4,2)& "/" & MID(TRIM(A1),6,2) & "/" & MID(TRIM(A1),8,2)
In Google Sheets, I need to combine a date with a string. These are the contents of my three cells:
cell formula shows
A1 05/11/2014 2014-11-05 (the cell is formatted as date)
B1 JS JS (text)
C1 A1 & B1 41948JS
I need cell C1 to display 2014-11-05JS - i.e., a combined string containing the date.
How to achieve this?
Please try:
=left(A1,5)&mid(A1,6,2)&right(A1,3)&B1
(I am assuming there are typos in your question).
Use CONCATENATE function.
Example:
= CONCATENATE(A5, " ", A6)
Importantly, In default date will not properly get appended. You need to select date field(s) and format it is "Plain Text". Option can seen at Format >> Number >> Plain Text
More functions are given here
You can use the CONCATENATE (or CONCAT) function. Each of them has advantages:
CONCAT can combine number and string
CONCATENATE can use many arguments at the same time
so you can use
CONCAT many times
or
CONCATENATE + many TO_TEXT
Extract the date components using YEAR, MONTH and DAY functions.
Following up on this earlier question: Excel - Convert date from yymmdd to dd/mm/yy
I would like to input only 4 digits and the formula convert to a date.
For example, if I enter value 1207, the formula will convert into 12/07/2014 but if I input 0311 it converts into 31/1/2014.
I couldn't work out how to do the date conversion when I input a date starting with "0" such as 0711.
The formula I'm using:
=LEFT(A2,2)&"/"&MID(A2,3,4)&"/2014"&RIGHT(A2,0)
See the wrong output highlighted below:
Input Date converted
1112 11/12/2014
1503 15/03/2014
2407 24/07/2014
2912 29/12/2014
0712 71/2/2014 <~~~~~~ should be 07/12/2014
0311 31/1/2014 <~~~~~~ should be 03/11/2014
You can use the formula as suggested by Jerry. I have same formula:
=DATE(2014,RIGHT(A2,2),LEFT(A2,2))
But, You need to make sure that your inputs are text. 0712 should be displayed as 0712 in excel. i.e keep you input to four digits then only this above formula will work. You can use apostrophe before 0712 to convert it as text, enter '0712 as input.
I'm not sure how you edited the other formula, but it should be working. In any case, there's one that works for your particular case:
=DATE(2014, RIGHT(A2,2), LEFT(A2,2))
Where A2 contains the date.
If your dates are actually numbers, then you might want to use a condition to change the result if the number is of different length:
=IF(LEN(A2)=4, DATE(2014,RIGHT(A2,2),LEFT(A2,2)), DATE(2014,RIGHT(A2,2),LEFT(A2,1)))