change cell format to general or text? - excel

we have sort of data in excel like this ---> 34:5:20
excel likes to consider it as time or date.
here is the problem because I know it's not a date and what ever action I want to do with it again
excel thinks it's a date/time value .
how can I stop this behavior ?
(each of the ':' delimited values has a special meaning to me but not date/time)
thanks a lot.

There is one option though, you can use the formula below, to convert the dates back to your format
=CONCAT(" ",TEXT(A2,"[h]:mm:ss"))
I am adding a space using concat function just so that if you ever decide to convert all to value, it will not return back to dates

I found the solution finally .
copy column to notepad.
select another column
change it's format cell to text.
now paste from notepad.
now my data is considered as text and I can separate the values using "column to text" from DATA tab.
thank you all for your valuable time.

Related

keep leading zeros when I add quotation mark in excel

I have a list of SSN in my excel file (9 digits, some of which have leading zeros, no hyphen).
I keep them in the special format (numero da seguranca social in portugues) so I can keep leading zeros in the column.
I want to add ' ', to the column so that I can search them in SQL query in bulk.
When I use concatenating formula ( concatenating("'",B2,"'",",")), the leading zeros are gone.
How can I achieve the result of 00XXXXXX as '00XXXXXX', ?
Thank you!
I am not sure what your special format is, but I am guessing that if the value is xx the format makes it look like 00xx. Similar to a zip code.
So the value when you change it to text looks like xx.
I can think of 2 ways to fix it
Write a formulae which basically does what the special format does. For example it would make xx as 00xx. Then you can concatenate this new value like u mentioned earlier
Copy the values from excel to notepad and then paste it to excel again. When you copy from excel to notepad, the formatted value, i.e. 00xx will get copied to notepad which can then be pasted to excel in a separate unformatted cell.
One way of doing this is to copy your SSN column from your file and paste it into a new file all by itself. Then, while ensuring that the SSN numbers are formatted with any appropriate leading zeros, save the new file as a text/tab delimited file and close it. Now, using Excel's Open File command, select your text file and on Step 3 of 3, select Text for the Column data format. Now, you should be able to select that column of data and copy it back to your main file and perform your concatena
Did you try ''00XXXXXX' or "'00XXXXXX"? That is, add one single quote before the number and Excel interprets it as a string, not a number. If you will not do any numeric operations with it, then it should be a string.
Thank you all for your input.
I ended up using #tigeravatar 's method, which is
="'"&TEXT(B2,"000000000")&"'"&","
and it worked for me.
Thank you!

Convert text date/time to a real date time in excel

My data is extracted from an application and it has a text that looks like a date/time in excel. How do I actually convert "3/24/2016 11:22:07 PM" (in text) to a real date/time conversion? I've tried formatting the cells but it doesn't work.
For a date conversion:
=DATEVALUE(TEXT(A1,"MM/DD/YYYY"))
For a time conversion:
=TIMEVALUE(TEXT(A1,"HH:MM:SS"))
For datetime conversion:
=DATEVALUE(TEXT(A1,"MM/DD/YYYY"))+TIMEVALUE(TEXT(A1,"HH:MM:SS"))
Where A1 has the data you wish to convert.
By the way, then you may wish to format the cell to a date/time or whatever.
Hope that helps.
1) try using the DATEVALUE function and see if that works for you.
2) A more reliable way, since datevalue does not always work is to strip the text out manually and insert it into and excel date value. You are going to want to use a combination of the following functions:
DATE
TIME
IF
FIND
MID
LEFT
RIGHT
LEN
Now in my opinion the easiest way to do this is to work with multiple helper columns to build out all the steps. One column per step. When you get your final answer, you can substitute or copy paste your formulas from the helper columns into the final formula until you are left with one variable. The reason I say this is that the final formula referring to only 1 variable gets rather lengthy/ugly and very hard to trouble shoot if you make a typo, forget a bracket or something goes wrong. When I did this approach I used a totally of 14 columns (includes final formula). When I packed it all up into 1 formula it resulted in this:
DATE(RIGHT(LEFT(A3,FIND(" ",A3)-1),4),LEFT(LEFT(A3,FIND(" ",A3)-1),FIND("/",LEFT(A3,FIND(" ",A3)-1))-1),MID(LEFT(A3,FIND(" ",A3)-1),FIND("/",LEFT(A3,FIND(" ",A3)-1))+1,FIND("/",LEFT(A3,FIND(" ",A3)-1),FIND("/",LEFT(A3,FIND(" ",A3)-1))+1)-FIND("/",LEFT(A3,FIND(" ",A3)-1))-1))+TIME(LEFT(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))-1)+IF(AND(LEFT(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))-1)<12,RIGHT(RIGHT(A3,LEN(A3)-FIND(" ",A3)),2)="AM"),0,12),MID(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))+1,FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))+1)-FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))-1),MID(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))+1)+1,2))
Note it is set up using cell A3 as the one with the time as text that needs formatting.
3) You should also be able to use excel's text to column function located on the DATA ribbon about half way across.
4) And of course there will be a way to code it through VBA as an option as well.
=DATEVALUE(A1)+TIMEVALUE(A1) seems to work as well, since each function only returns the value corresponding to what it recognizes in the string. That is, DATEVALUE() ignores the time component, while TIMEVALUE() ignores the date component.

Excel weird behaviour with dates => text

I have a ton of cells that contain dates such as 22/12/2013. This is set automatically as Date format. And if I try to change the cell format to text (Simply because I want it to be text rather than a date so that I can read it later with PHP), the thing changes completely.
Here's how to replicate the error.
Write in a cell 22/10/2013
Change the format to TEXT
The original content gets changed to 41569
I need a way to fix this, because otherwise when I read the date with PHP, it gets convereted to 41569 nonetheless. But if I manage to make it text, it will be alright.
As andy holaday says, using cell formatting to change the format won't actually change existing numbers (dates) to text. You can do that with "text to columns" functionality:
Select column of dates > Data > Text to columns > Next > Next > at step 3, under "column data format" choose "text" > Finish
That converts existing dates, if you have dates to enter which you want to enter as text you can add an apostrophe, as Polly says, or you can simply pre-format the entry column as text format.
It's not an error. Changing the format of a cell does not change the value that is stored in that cell. Excel stores dates as numerical values. What I think you want to do is change the numerical value into text that resembles a date. Try this formula in a new cell somewhere:
= TEXT(A1,"dd/mm/yyyy")
Enter your dates with an apostrophe at the beginning. '22/10/2013 will be interpreted as a text string.

Within excel 2010 how can I convert text formatted number ###### into time formatted as mm:ss.00

I have found other similiar topics on the forum but I am struggling to find a way in excel 2010 to convert text formatted numbers ###### into time formatted as mm:ss.00
Any assistance offered would be really appreciated and it would save me lots of data entry time and data entry errors.
thanks
Nigel
The ###### could simply mean your column widths are too small. Try expanding them and see if that works. Otherwise, you can modify the format (cell data type) by simply right clicking it and selecting "Format cells...". From there, you can select the "Time" format or create your own in the "Custom" format, both located under category.
If you always want the milliseconds to be "00", you may want the custom format mm:ss:"00"
Try this:
Where your text column begins in A1, and result column begins in B1
Custom formatting for column B, mm:ss.00;#
=TIME(,LEFT(A1,LEN(A1)-4),MID(A1,LEN(A1)-3,2))+TIME(,,RIGHT(A1,2))/100

Storing numbers are text Excel 2007

When numbers are stored as text in Excel you see this little guy http://imgur.com/zXdwD
in the upper-left hand corner. when you click on it it gives you the option of converting the text representation of a number to a number upon which math can be done. also, when stored as text numbers appear on the left side of the cell opposed to the right one. I have an array of numbers which are stored as text, but they don't offer that little green thing to convert them to numbers. It may sound trivial but I'm using the Vlookup function to reference a large column of numbers to a code name, but it's not being recognized. And the only thing I can think of is that it's somehow being read differently (the codes are most defintely in the lookup table, and ctrl+f will find them). I want to know if anyone has an idea about what's happening.
Thanks.
The smart tag is a little finicky at times. There's a couple of things you can do.
If you're using code, you can multiply the cells in the range by 1, this will convert them to a number.
Alternatively you can convert the number you're matching to a string and then vlookup. Something similar to:
=VLOOKUP(TEXT(A1,"#"),B1:D10,2,false)
Note TEXT(A1,"#") would round to no decimal places, you may have to adjust the formatting.
The format of some of the cells in the lookup table maybe formatted as text. If there are a lot of them you can create a macro that corrects them. I had the same issue in this SO question although it was the opposite problem.
Another way to correct them would be to copy all the cells in the lookup table in that column and in an adjacent blank column edit>paste special>values>add which makes each of them numeric. Then copy them and paste those back over the originating cells.
A quick trick to convert all numbers formatted as text back to umber format is to copy the data into the "Notepad" application. Then select and copy the data from "Notepad back into your spread sheet and everything will be converted to number format.

Resources