Extract characters from a cell with format h:mm - excel

*I use Excel in spanish.
I have a cell with format h:mm (A1 = 07:35), and I want to extract the first two characters in one column (B1=07), and the others into a different one (C1=35).
When I apply the EXTRACT formula (B1=EXTRAE(A1;1;2), C1=EXTRAE(A1;4;2)), it does not throw the numbers that I ask, because of the format, the formula only recognize TEXT format, not h:mm (it shows B1=0, and C1=30, because A1=0,330555556 in text format).
What formula does what I want or how can I get the numbers that I need?
Thanks.

EXTRAE is a version of MID() function in English and MID function works on text values as you indicated. So first convert the cell into a text value and then extract
=MID(TEXT(A1, "hh:mm"), 1, 2)

From your example I believe you are try to extract the Hour and the Minute components of a time. If you want the Hour or Minute of a time value use the =HOUR(A1) Function for extracting the hour and the =MINUTE(A1) Function for extracting the minute.
Format the cells to be 00 so that the cells show two digits for values below 10.
Don't know their equivalent functions in Spanish but hopefully that gives you a point in the right direction.

If your time is stored as text, you will need to parse it somehow. In the simplest case, you can use IZQUIERDA() and DERECHA() to get the leftmost or rightmost characters respectively.
=IZQUIERDA(A1,2) and =DERECHA(A1,2)
If your times are stored as a date, you should use
=MINUTO(A1) and =HORA(A1)
However, if you have a more complex date and are unable to use VBA, you'll have to perform some sort of evil splitting to find it.. For example:
A1
Event 07:35 am
B1 Hour
=IZQUIERDA(RDERECHA(A1,LEN(A1)-SI.ERROR(HALLAR(" ??:??",A1)+1,HALLAR(" ?:??",A1))),HALLAR(":",RDERECHA(A1,LEN(A1)-SI.ERROR(HALLAR(" ??:??",A1)+1,HALLAR(" ?:??",A1))))-1)
C1 Minute which depends on the Hour to function
=IZQUIERDA(RDERECHA(A1,LEN(A1)-HALLAR(B10&":",A1)-1),2)
Here's my attempt at an example demonstration
Disclaimer: the Spanish translations of formulas are according to this internet source

Related

Excel extract text between identical characters

I want to extract the date from the following text:
Thu 11/29/18
I was thinking to use MID function however the length of the month can change depending on the month (e.g. 1 vs 10). Likewise the day starting index and ending index are variable values and depend on the same character '/' to determine its start and end. How might I differentiate the first '/
' from the last '/'?
If you are just trying to convert the date then follow Gary's students advice or the plethora of other answers on how to convert a date from TEXT to a DATE or a date from this format to that format.
If you are truly looking for any example of retrieving the text between the first two sets of identical numbers, you could use a formula such as
=MID(A1,FIND("/",A1)+1,FIND("/",A1,FIND("/",A1)+1)-FIND("/",A1)-1)
With text in A1, in another cell enter:
=DATEVALUE(MID(A1,FIND(" ",A1)+1,99))
Explanation:
we grab the part of the string after the space: 11/29/18
DATEVALUE() changes this to a true Excel date.

Change decimal number directly into hour in Excel

I need to convert lots of numbers that represent hours, into actual Excel values formatted like hours.
In e.g., I have a cell that has the value "16.30", and I need it to be "16:30".
I tried replacing the dot with two dots, formatting the cells with a custom format like "00:00" and "hh:mm", but nothing works. Excel returns an error or changes the value of the hour by converting the numeric value into an hour, as usual.
Any ideas about how to achieve the goal listed above?
TL;DR: how to change a cell with a value "16.30" into "16:30" as an hour?
Thanks in advance
One way to make your idea of substituting ":" for "." work is like this:
=TIMEVALUE(SUBSTITUTE(TEXT(A1,"0.00"),".",":"))
if A1 contains 16.3 and A2 contains the above and is formatted as time then it will display as time.
You can use this:
=TIME(INT(H6),(H6-INT(H6))*100,0)
Where H6 is your cell. Then format it as you want.

date conversion formula in excel

I have some dated in this format "09-MAY-13 06.42.46.097127000 PM" and need to convert to this format "2013-05-09T18:42:47.132Z". my goal is to find out which happend earlier. I am not sure how to format these dates.
2013-05-09T18:42:47.132Z 09-MAY-13 06.42.46.097127000 PM
2013-05-08T20:56:55.821Z 06-MAY-13 03.22.09.129443000 PM
2013-05-08T20:51:45.287Z 06-MAY-13 03.03.22.975700000 PM
2013-05-08T20:55:34.719Z 06-MAY-13 10.40.55.924181000 PM
How I can do that??
I originally posted an answer which converted one of your formats to the other. I now see that you need to compare them, so you can convert this format in A2 to date/number values ....
09-MAY-13 06.42.46.097127000 PM
.....with this formula
=SUBSTITUTE(SUBSTITUTE(A2,".",":",1),".",":",1)+0
and this format in A3
2013-05-09T18:42:46.097z
....with this formula
=SUBSTITUTE(SUBSTITUTE(A3,"T"," "),"z","")+0
You can format the results how you like, leave as numbers or format as m/d/yyyy hh:mm:ss.000 or similar. you can now compare easily with a formula like
=B2>B3
or get the smaller or larger with MIN or MAX
If have a value of your original style in cell A1, place the following formula in a different cell:
=DATE((2000+MID(A1,8,2)),MATCH(MID(A1,4,3),{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"},0),LEFT(A1,2))+TIME(MID(A1,11,2)+IF(RIGHT(A1,2)="PM",12,0),MID(A1,14,2),MID(A1,17,12))
Then, in that target cell, apply the following format:
yyyy-mm-ddThh:mm:ssZ
Please note the following:
This assumes that all of your months are 3 characters (JAN, FEB, MAR). Since your example was "MAY" (already 3 characters), I don't know with certainty how your other months appear. Longer month names complicate the formula a bit. I can help with this if you need it and don't know how to do it.
I couldn't find a way to force Excel to display fractional seconds in the context of such complex date/time formatting, even though your example showed seconds subdivided to the thousandths. Hopefully this isn't a deal-breaker. If it's necessary to display fractional seconds, you may need to handle this with a separate formula to display the result as text, independent of the formula above, which you can use for your calculations of which date came earlier.
To add to Joe's answer...
To get Excel to compare one column to the other you need to do the same sort of manipulation from the first column as the second.
That would look like
=DATE(LEFT(A1,4),MID(A1,6,2),MID(A1,9,2))+TIME(MID(A1,12,2),MID(A1,15,2),MID(A1,18,5))
Once you have a new column for each of these transformations it should be simple to have Excel compare them.

Converting a string to a date in a cell

I have 100.000 rows of data in Excel. Some of the fields are dates, but the fields in Excel are as text. I need these fields in number format including both dates AND time (e.g. 21.10.2011 13:10:50). Formatting the cells doesn't work because that doesn't change the datatype. I can pick out the date and time with formulas but not get them in the same cell.
So what I am looking for is the formula to calculate the number representation of a date (the one you see if you format a date as a number).
Have you tried the =DateValue() function?
To include time value, just add the functions together:
=DateValue(A1)+TimeValue(A1)
To accomodate both data scenarios you have, you will want to use this:
datevalue(text(a2,"mm/dd/yyyy"))
That will give you the date number representation for a cell that Excel has in date, or in text datatype.
I was struggling with this for some time and after some help on a post I was able to come up with this formula =(DATEVALUE(LEFT(XX,10)))+(TIMEVALUE(MID(XX,12,5))) where XX is the cell in reference.
I've come across many other forums with people asking the same thing and this, to me, seems to be the simplest answer. What this will do is return text that is copied in from this format 2014/11/20 11:53 EST and turn it in to a Date/Time format so it can be sorted oldest to newest. It works with short date/long date and if you want the time just format the cell to display time and it will show. Hope this helps anyone who goes searching around like I did.
The best solution is using DATE() function and extracting yy, mm, and dd from the string with RIGHT(), MID() and LEFT() functions, the final will be some DATE(LEFT(),MID(),RIGHT()), details here

Format all cells in column from date to text

I have an excel document with about 500 rows.
I need to format all the cells in , let's say, B column from date to text.
This is how it looks like now:
2012-06-15
2012-06-01
2012-06-14
What it looks like when formated to text:
41075
41061
41074
It has come to my understanding that this is a timestamp representing days since 1st januari 1900, right? Anyhow, this is not what I want. I want the value of the field to be exactly what it is but with the column type of text. I've found various solutions for this using functions like this: =TEXT(B1, "yyyy-mm-dd") but that is not reformating the cell, it is extracting a value from one cell, reformat it and represent is as text in another.
The rule I'm after: I want all cells in B column to have the type text without changing the value
Thanks!
If you have a situation where columns A to D are dates of 500 rows you then:
Use the =TEXT(A1, "yyyy-mm-dd") function you describe in cell E1.
Copy this formula 4 columns wide, and 500 rows down.
Then copy and paste values to the preceding cells.
Copy Example:
Output:
You're right, Excel stores dates internally as number of days since January 1st, 1900 (apart from a minor leap year bug).
Thus, I'm afraid you cannot have both:
Either you keep the value e.g. (41075) and simply format it as a date, so it'll be displayed as 2012-06-15 -
Or you convert it to text format - but then you either
Lose the underlying value - if you convert it to the format you wish with a text function as you mentioned
Keep the value (41075), but cannot see the date
If you are typing in the values you can by adding a ' before the values to keep it as text.
e.g.
But depending on the method the third party service uses to import these values this may not work and I bet you will not get around it unless you export it to a text editor and import it again.
Also try to play with diferent types of text for your third party service, e.g. "2012-06-15" as some see the quotes and remove them.

Resources