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.
Related
When I have a date like 2/12/2022 in a cell in an excel document (say in the cell A1),
=year(A1)
gives 2022, but this does not work for a date like 2/12/1875.
Indeed it returns #Value!.
2/12/1875 is before the beginning of the date system in Excel.
To see the beginning, as per your system, write 1 and format as a date:
In general, using the =YEAR() formula is not possible before the beginning of the first serial number, thus you should resort to other options. Like this one:
=RIGHT(A2,4)
or a more complicated one, that gives the last element in A2, separated by "/":
=RIGHT(A2,LEN(A2)-SEARCH("/",A2,SEARCH("/",A2,SEARCH("/",A2)+1)))
Try this-
=TAKE(TEXTSPLIT(A1,"/"),,-1)
I am trying to change the date format of my cells in excel to another date format. Currently it is in this format: apr, 10, 2017 01:58:24 PM. I would like to have it in a normal format like dd-mm-yyyy without the time, but I can not get it to work with the formatting in excel.
Thanks in advance,
Kester
You could use this:
=(MID(A2,FIND(",",A2)+2,FIND(",",SUBSTITUTE(A2,",","#",1))-FIND(",",A2)-2)&"-"&LEFT(A2,FIND(",",A2)-1)&"-"&MID(A2,FIND(",",SUBSTITUTE(A2,",","#",1))+2,LEN(A2)))*1
Which is basically a bit of string manipulation (and some substitution of , to # to help) to put it in the generic format 'd-m-y h:m:s t', which excel understands, then multiply the string by 1 to force into a number (in this case 42835.58222); which you only have to format as date (important!):
Edit: Per comments, the first comma doesn't actually exist, so the revised formula:
=(MID(A2,FIND(" ",A2)+1,FIND(",",A2)-FIND(" ",A2)-1)&"-"&LEFT(A2,FIND(" ",A2)-1)&"-"&MID(A2,FIND(",",A2)+2,LEN(A2)))*1
With data in A1, in B1 enter:
=DATE(MID(A1,10,4),MATCH(LEFT(A1,3),{"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"},0),MID(A1,6,2))
and apply desired formatting:
(this results in a genuine Excel date that can be used in sorts, calculations, etc.)(this assumes that the day field is always two digits)(if your month list is in a language other than English, edit the month list)
*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
Hi I need a formula that converts a string in the format:
"05th February 2015"
To data value. Unfortunately this is the raw data format that has to be used.
The only way currently I can think might be possible to do this is to chop the string for the day and year and then use an if statement to change the month name into a number, then use the DATEVALUE function.
Does anyone know of a solution?
Please try:
=1*(left(A1,2)&right(A1,len(A1)-4))
then format to suit.
The issue here with persuading Sheets to recognise a date in text format is mainly to remove the ordinal indicators. This can be achieved by picking off the first two characters and concatenating them to all the remaining characters other than the ordinal indicators. (Sheets offers various other ways to do so with corresponding results.)
Once the appearance is recognisable by Sheets it is just a matter of coercing Sheets to convert from text to number format, which can be achieved by 'multiplying' by 1 (again, Sheets does have other options for this).
For the above to work the text for month name must suit the spreadsheet setting locale.
I have been using the following as a formula array beginning in column R2 for an Excel spreadsheet that combines the data from four columns:
=L2&" "&N2&" "&Q2&" "&P2
Column L contains the date in the following format: 2/23/2015.
The formula used to show the date as shown above, but now for some reason the format has changed to go from 2/23/2015 to 42081.
I can't seem to get date to show as it once did. Also the Excel spreadsheet I apply this to is downloaded from a different source each day so I don't know if default formatting has changed even though the data is exactly the same.
When you concatenate like that you just get the values not the formatting because number formatting doesn't apply in the text string created. You can use TEXT function to dictate the format in this context, e.g.
=TEXT(L2,"m/d/yyyy")&" "&N2&" "&Q2&" "&P2
With MDY convention, if L2 is formatted as Text prior to entry then keying in 2/23/2015 would preserve that display in a formula that concatenates it with other strings. Similarly if not keyed but entered with Ctrl+:.
If L2 is formatted as General or Short Date the date index will be concatenated (42081 in the example above) though the display in L2 will not change.
While a change in formatting may be the most likely explanation (and a solution provided by #barry) another possibility is a change in the date convention from DMY. In which case 2/23/2015 would have displayed and concatenated as that even in a cell formatted as Short Date. 2/12/2015 in that case however would have displayed as such but in the 1900 date system concatenated as 42340 - the date serial number for December 2, not February 12.