Convert text string (1st/2nd etc) into dd/mm/yyyy - excel

I need to try to convert a basic string i.e. 1st, 2nd, 3rd into a date formatted as dd/mm/yyyy where the mm/yyyy part are this current month and year and the day equals the "number" in the cell.
For example
Cell K5 contains the string "1st"
Formula in cell A5 takes K5 and converts to 01/11/2019
Is there a way to do this?
Thanks for the help in advance

Use this to strip the last two characters:
=DATE(YEAR(TODAY()),MONTH(TODAY()),LEFT(A1,LEN(A1)-2))
Then format as desired. Mine is mm/dd/yyyy

Do you mean like this:
If so, you have to remove letters from selection then excel will convert them into date. For clarity, remove letters, then convert cells to date format.

Related

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

Extract characters from date cell in excel

I have a date cell 25/10/2002 in date format with the text format (if i change the format to text) as 37554. How do i pull the months and year values from this.
If i do =RIGHT(cell,4) for the year it pulls out 7554
You can simply use:
=MONTH(cell)
And
=YEAR(cell)
As it should evaluate text just fine.
You can use =TEXT(Cell value,"mm-yyyy") ##will provide you Month and year in MM-YYYY format

How to convert MM/YY to MM/DD/YYYY in Excel (missing day)

The day is missing so it just needs to be first of the month so:
11/17 would be 11/01/2017
Is there a formula that can do this?
There is two approaches:
Set the Category type of the cell (in Format Cell) as Custom and define this format in Type field: mm/dd/yyyy
In case of the format cell is text (working with string)
Assuming the validate entered in cell A1, use below formula:
=LEFT(A1,2)&"/01/"&IF(LEN(A1)=8,2,20)&RIGHT(A1,2)
This is probably a stupid formula but it worked for me;
=DATE(100 + RIGHT(TEXT(A6,"MM/YY"),2),LEFT(TEXT(A6,"MM/YY"),2),1)
Try it out it takes the existing "MM/YY" format and converts it to a MM/DD/YYYY date using the date foromula =DATE(Year,Month,Day). It works if the date is in date format or text format.

Identifying date in text file While date is incorrectly formatted

I need to extract the date from C2 and find the difference between the date in c2 and A1
The date is formatted as "Jul, 18 2015", any ideas? EDIT the database has a different amount of text per cell. Is there away around this so that i can apply the formula to every cell and pull the day/month/year?
you are going to need to go through a series of string manipulation and date time functions. Lets start by assuming your string is in the C2 cell. In order to do this we are going to work from the largest unit (years) to the smallest unit (days). You can do it in any order as it will all be lumped into once formula, but for the breakdown of steps its good to have an order.
Step 1) PULL OUT THE YEAR
=MID(C2,FIND(" ",C2,FIND(" ",C2)+1)+1,4)
That will give us the last 4 characters of the string after the second space which in this case is the year.
Step 2) PULL OUT THE MONTH
=MONTH(DATEVALUE(MID(C2,2,3)&"-"&1))
that looks at second character and pulls out the string 3 character long which is your month. It then converts it to a format that excel tends to recognize as a date short form by adding a - and the digit 1 to it. So in your case if would look like Jul-1. Datevalue converts this to an excel date serial, which we then pull back and grab the month from and in your case that is 7
If the above formula does not work for you it could be due to regional settings. If that is the case you can use the following:
=MATCH(MID(C2,2,3),{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"},0)
If you use this alternat formula , be sure to adjust the final equation accordingly.
Step 3) PULL OUT THE DAY
=TRIM(MID(C2,FIND(" ",C2)+1,2))
So the above formula finds the first space and then starts pulling then next 2 characters after it. Now since I do not know if the first of the month is 01 or just 1, it may wind up grabbing the space after the 1. The trim function removes excess spaces.
Step 4) BUILD THE DATE
The DATE function in excel requires the YEAR, MONTH, and DAY and converts those values in to the excel date serial. In this case we will convert:
=DATE(year,month,day)
to the following by substituting our equations from above:
=DATE(MID(C2,FIND(" ",C2,FIND(" ",C2)+1)+1,4),MONTH(DATEVALUE(MID(C2,2,3)&"-"&1)),TRIM(MID(C2,FIND(" ",C2)+1,2)))
The final touch is to ensure your cell is formatted as date and not General or some other format which will result as the date being displayed in an integer format.
Now assuming you date in A1 is in Excel format, you would simply add A1- to the front of the last formula to give you:
=A1-DATE(MID(C2,FIND(" ",C2,FIND(" ",C2)+1)+1,4),MONTH(DATEVALUE(MID(C2,2,3)&"-"&1)),TRIM(MID(C2,FIND(" ",C2)+1,2)))
Now, if A1 is also in quotes like the C2 formula, repeat the formula for stripping the date out of C2 but use A1 as the reference and substitute it in for A1 in the last formula to give:
=DATE(MID(A1,FIND(" ",A1,FIND(" ",A1)+1)+1,4),MONTH(DATEVALUE(MID(A1,2,3)&"-"&1)),TRIM(MID(A1,FIND(" ",A1)+1,2)))-DATE(MID(C2,FIND(" ",C2,FIND(" ",C2)+1)+1,4),MONTH(DATEVALUE(MID(C2,2,3)&"-"&1)),TRIM(MID(C2,FIND(" ",C2)+1,2)))
FORMULAS USED
Text/String Functions
MID
FIND
TRIM
Date/Time Functions
DATE
DATEVALUE
MONTH

Convert text to date in Excel

Currently I exported some data, from a database using a query in which each row for a "comment" column begins with a date formatted as MM/DD/YY.
I used the =LEFT(TEXT,8) function to only extract the date but it happens that the some of the dates are formatted inconsistently so we may have some that are M/D/YY where the month or day isn't two digits, this will then include a ';' as a separator since it is less than 8 characters.
Is there a way I can format the text so the ';' is excluded? That way I can sort the data.
I think the DATEVALUE function does most of what you need. It takes in many different date formats (M/D/YYYY, MM/DD/YYYY etc) and converts it to an excel date (i.e. # of days since 1/1/1900).
The formula below says:
If the date is clean then just apply DATEVALUE function
If there is an error, just use the part to the left of the ';'
Assuming 9/1/2013 is Cell A2:
Input Data Sortable Excel Date
---------- -------------------
9/1/2013; =IFERROR(DATEVALUE(A2),DATEVALUE(LEFT(A2,FIND(";",A2)-1)))
09/2/2013; 9/2/2013
10/1/2013; 10/1/2013
10/10/2013 10/10/2013
I've made a live Excel sample here.
Assuming your text looks like this: ;1/;2/13 or 1/2/13;; or ;;1/2/13
You can use substitute like this:
=SUBSTITUTE(A1,";","")
The result will be:
So if date is either the first 6, 7 or 8 characters of A2 you can get the date with this formula
=LOOKUP(10^10,LEFT(A2,{6,7,8})+0)
format result cell in required date format
As the result is a valid date you can sort these as you would sort numbers

Resources