How to format a formula - excel

In one column (E) I have values such as 2014-10-28 19:40:00+00:00. This is obviously date and time.
In my (F) Column I want to just use the date from that, so I've used the formula =LEFT(E:E,10) which worked nicely.
In my (G) Column I want the time, so I used =RIGHT(E:E,14) and it shows up with "19:40:00+00:00" which is what was expected.
Now I am trying to format the cells to have the time show up in a standard format of hh:mm. When I right click and select this format, nothing happens.
Is there a way to format the output of a formula or no?

RIGHT and LEFT return strings, return them to their numeric values using the VALUE formula
=VALUE(LEFT(...))
Should allow you to use custom formats again

If E1 contains:
2014-10-28 19:40:00+00:00
Then in G1 enter:
=MID(E1,12,5)

if your value in E is a date value, then =INT(E1) will extract the date, and =MOD(E1,1) will extract the time
If your value in E is text, then =INT(DATEVALUE(E1)) will extract the date, and =MOD(DATEVALUE(E1),1) will extract the time
Both will be in recognized formats for excel, and can then be formatted in any way you desire

Related

date format as yyyy/dd/mm and convert into dd/mm/yyyy in excel

i have a column in excel where data is in mix format as some date are in dd/mm/yyyy and some date are in yyyy/dd/mm
i want to convert dates which are only in yyyy/dd/mm --> dd/mm/yyyyhttps://i.stack.imgur.com/5SOV1.png
what is the way i can do this?
i tried concatenate(left()) and concatenate(middle()) and concatenate(right()) and then concate() to combine all this 3 different fields but then it is messing up the true date format i want that is dd/mm/yyyy as some dates are already in dd/mm/yyyy and i made used concatenate() for format yyyy/dd/mm
Let's say you have the input data in text format in column A. In column B you have the output in the equivalent date format (not text format). This is the proper way to handle dates. You asked to convert it to another text format, but I think it is better to have them as an Excel date type.
The following formula does that:
=LET(rng, A1:A4, texts, DROP(REDUCE("", rng, LAMBDA(acc,text,
VSTACK(acc, TEXTSPLIT(text,"/")))),1),
first, INDEX(texts,,1), second, INDEX(texts,,2), third, INDEX(texts,,3),
MAP(first, second, third, LAMBDA(a,b,c, IF(LEN(a)=4, DATE(a, c, b),
DATE(c, b, a))))
)
The formula returns an array, so there is no need to drag down the formula, useful for a large input data set. If you prefer to drag the formula down, then you can use the following formula:
=LET(text, TEXTSPLIT(A1,"/"), first, INDEX(text,1,1), second, INDEX(text,1,2),
third, INDEX(text,1,3), IF(LEN(first) = 4, DATE(first, third, second),
DATE(third, second, first))
)
Note: If you really want the dates in text format, then you can do it by replacing DATE function with: a&"/"&c&"/"&b and c&"/"&b&"/"&a respectively or to encapsulate DATE output with TEXT function, for example, TEXT(DATE(a, c, b), "mm/dd/yyyy") in the format of your preference.
Here is the output:
The previous solution works because we have a way to identify the year as a 4-digit number. If the year has 2-digits, then you need to build a logic to differentiate a year from a month or a day.
Because the data is in Excel date format (internally it is stored as a whole number), then you can format the date in the format of your preference without changing the data. In the screenshot, you see the dates in mm/dd/yyyy format. Having the data as a date type, you can use all Excel functionalities for working with dates. Having dates in text data type will have more limitations.
Here is the output using the UK locale and returning the dates in dd/mm/yyyy, but it is the same output data, just different visualization:

How to reformat this date in excel

How do I reformat this to yy/mm/dd in excel? text to column doesn't work.
Select the range, right click, format cells, select custom, type: "yy/mm/dd".
Text dates are not date values.
You should convert the text to date values first.
You can use =DATEVALUE(text) to get the date value from the text date.
However, the weekday should not be in the text. DATEVALUE function does not accept it. So, you have to trim that first.
For example, find the first "," and drop out that with additional two letters.
=DATEVALUE(MID(A1,FIND(",",A1)+2,LEN(A1)))
And, you have to format the date cell to yy/mm/dd.
Then, the result should be like this

Excel convert date to text retaining date layout

I have rows containing every Monday and Sunday in an entire year, (with variations on when a month starts and ends) like so,
11/05/2015 18/05/2015 25/05/2015 01/06/2015 08/06/2015
17/05/2015 24/05/2015 31/05/2015 07/06/2015 14/06/2015
However these are in the date format, and I need them in a text format, but so they still read in the dd/mm/yyyy format, not like 42125.
Further up my document, each column header should read dd/mm/yyyy-dd/mm/yyyy using each of the dates shown in my first example, and I was hoping to achieve this using the formula =A30&"-"&A31 and so on. So the desired outcome should read,
11/05/2015-17/05/2015 18/05/2015-24/05/2015
11/05/2015 18/05/2015
17/05/2015 24/05/2015
However using the =cell&cell formula im left with
42135-42141 42142-42148
11/05/2015 18/05/2015
17/05/2015 24/05/2015
I have to create these headings for 2 years worth of dates, and trying to avoid typing every heading out manually, is there a way to achieve this?
Use the TEXT function which comes with Excel.
Assuming cell A1 has "11/05/2015", use the following formula in cell B1:
B1=TEXT(A1,"dd/mm/yyyy")
This takes care of the first part of your question. For the second part, you can use the CONCATENATE function. Assuming that B1 and B2 contain dates as text, you can join them together using the following formula:
=CONCATENATE(B1, "-", B2)
Try converting those values to text before concatenating:
=TEXT(A1,"dd/mm/yyyy")&"-"&TEXT(A2,"dd/mm/yyyy")
You need to break them down like so:
=DAY(A3)&"/"&MONTH(A3)&"/"&YEAR(A3)&"-"&DAY(A4)&"/"&MONTH(A4)&"/"&YEAR(A4)
I am assuming here your data start from cell A3
Assuming headings in row 1 and dates in rows 3 and 4 this will work:
=TEXT(A3,"dd/mm/yyyy")&TEXT(A4," - dd/mm/yyyy")
without having to concatenate " - "

Excel - Convert date from yymmdd to dd/mm/yy

I have an Excel file which is exported from a Access database.
I have 25000 records and I will need to replace all of them.
The date column is not formatted (yymmdd). I need to change the date format from yymmdd to dd/mm/19yy. For the yy I need to add a constant value 19 in front of it so it would be 19yy.
I have only 1 date column per row
Is there any way to convert all the 25000 record's column formatted in yymmdd to dd/mm/19yy in a few clicks?. Thank you
This will give you the result as an actual date which you can then format as you wish using Excel's date formatting options.
=DATE(1900+LEFT(A1,2), MID(A1,3,2), RIGHT(A1,2))
If you don't need to parse it into a date value, but merely need to display a date in the format you identified, the following will work on a value in cell A1 (copy down to the rest of the 25,000 values as needed:
=RIGHT(A1,2) & "/" & MID(A1,3,2) & "/19" & LEFT(A1,2)
In my cell A1, I entered the value 981116. This formula converted it to 16/11/1998. I think that's what you're looking for, right?
Assuming data starts at A2 put this formula in B2
=(19&TEXT(A1,"00-00-00"))+0
Now format B2 in required date format, e.g. mm/dd/yyyy
and you can easily "fill down" all 25000 rows by doing this:
put cursor on bottom right of B2 (first cell with formula) until you see a black "+" - that's the "fill-handle" - double click and the formula will populate as far down as you have continuous data in the adjacent column
Note: you can probably omit the 19& if all your dates are after 1930 because the default is to treat any date written without the century as 1900s if it's >=30 or 2000s if it's <30 [although you can change that in regional settings]

Have formula treat value as text, not numeric

I have an Excel formula reading data from a column. The data in that column is sometimes a date-like format, such as "10-11". Despite the fact that I've ensured that column is text formatted -- and all values display correctly as plain text, not reinterpreted as dates -- the formula is basically reinterpreting them as dates in the reference.
I need a way to force the formula's cell reference to interpret the cell as text. I tried TEXT(A1, "#") but it doesn't work -- it gives the numeric value of the date.
Brian Camire's answer explains why, but here's a worksheet function that will work for you. Note that you have to create that numeric array in it based on how long the longest string will be. It's an array formula, so when you first enter it you have to hit CTRL-SHIFT-ENTER, then you can click and drag it down the column.
=LEFT(A1, MATCH(FALSE, ISNUMBER(VALUE(MID(A1, {1,2,3,4,5}, 1))),0) - 1)
Short answer: When referring to number-like (or date-like) text values in a formula, don't use them in a place in the formula where Excel is expecting a number.
Long answer: Even if the source column is formatted as text and the values in the source column are truly entered as text (and not numbers, including dates), Excel may automatically convert text values to numbers (including dates) when you reference them in a formula if you use them in a place where Excel is expecting a number (or date).
For example (assuming US date formats), in a blank worksheet:
Set the format for column A to Text.
In cell A1, enter the value 10-11.
In cell B1, enter the formula =T(A1). The T() worksheet function returns the supplied value if it is text. Otherwise, it returns an empty string. The result of the formula in cell B1 should be 10-11, indicating that the value of A1 is text, not a number or date (in which case the result would be an empty string).
In cell C1, enter the formula =A1.
In cell D1, enter the formula =T(C1). The result should also be 10-11, indicating that the value of the formula in C1 is text, not a number or date. This shows that you can (sometimes) use a text value that looks like a number (or date) in a formula and have Excel treat it as text (which is what you want).
In cell E1, enter the formula =A1+0. The result will be 40827. This is the numeric value of the date October 11, 2011. This shows that you can (sometimes) use a text value that looks like a number (or date) in a formula and Excel will automatically convert it to a number (which is what you observed) if you use it in a place (like on either side of the + operator) where Excel is expecting a number.
To insert a value into a cell and have it not be auto-formatted, and just treated as text, you can enter it like this:
=("cell data")
eg:
=("+1 3456789")
When you use &"", Excel converts the results of a formula to text (like *1 would convert to numbers).
Thus, you can use this formula:
=TEXT(A1;"jj-mm")&""
If you put a single quote in front of the text in the cell, it should be represented as text on all references:
'10-11
Just add zero to the input!
I was having a similar problem where I had a list of numbers with a text prefix (like FOO-1, FOO-25, FOO-979) but I just wanted the number part (1, 25, 979) so I could run another formula off of that. I was using SUBSTITUTE to replace the text portion with blank, but my other formula using these numbers was coming up with bogus results. I ended up making my formula like this:
=SUBSTITUTE(B1:B10,"FOO-","")+0, and now the ISNUMBER is saying TRUE where before it was saying FALSE.
In my case, I have a form worksheet that is used by dealers to ad parts and have it calculate the final cost; it references a locked "products" sheet. The problem is that I had no way of controlling what they entered.
Products can be like:
101 = A true number
7-2009 = Reads as date
7-5601-RT = TEXT/NUMBER reads as both number or text (NOT SOLVED YET)
CP6072CD = reads as plain text
I have most of this figured out; the only one that isn't is the one that reads as both text/Number.
In case anyone is looking for a similar solution, i did the following:
I created three additional columns to test and display the three different cases: "NUMBER", "DATE" , "TEXT".
DATE: =NOT(ISERROR(DATEVALUE(B42)))
ISOTHER: =(ISNUMBER(--(MID(B42,ROW(INDIRECT("1:"&LEN(B42))),1))))
NUMBER: =ISNUMBER(B42)
NUMBER/TEXT: =NOT SOLVED YET
I42 = DATE
J42 = NUMBER
K42 = OTHER
L42 = TEXT
M42 = THE RESULT OF THE QUERY BELOW
=IF(AND(I42 = FALSE, J42 = FALSE, K42 = TRUE), "NUMBER", IF(AND( I42 = TRUE, J42= FALSE, K42=TRUE), "DATE", "TEXT"))
This (ABOVE) tests all the true/false results and depending on what the value turns out to be, I format each of them using:
ISNUMBER = VALUE(B42)
DATE FORMATTED AS B42*1
ELSE TEXT - AS ORIGINAL
=IF(M42 = "NUMBER", VALUE(B42), IF(M42 = "DATE", B42*1, B42))
So now I just need to figure out how to test if something is both text and number because the 7-5601-RT tests out as the same as number: "FALSE, FALSE, TRUE, TRUE"

Resources