mid formula to only include numbers?

keinz

New Member
Joined
Dec 2, 2015
Messages
44
the format 1/26/23 - i split it up into 3 different columns to represent each number with formulas (left, mid, right) then using the year formula to combine the 3
but the issue im getting is that since the 'year' is in 2 digits (23) in this case, its showing as 1923 rather than 2023 - how could I get around this?

so what i am doing is:

A1 = 1/26/23
A2 = left(A1,1)
A3 = mid(A1,3,2)
A4 = right (A1,2)
A5 = date(A2:A4)

A4 formula is showing the last 2 digits of the cell with the test 1/26/23 - which is 23
I just did =2000+23
this will help me get the proper year then I can use the DATE function to get the proper date

However - one thing I noticed is that for my "Day" cell - if its at the beginning of the month it will include the "/" which messes up the whole formula...

so for example
1/26/23

mid(a1,3,2) is showing 26 - perfect

but if the dates is 2/1/23
mid(a1,3,2) shows 1/

Is there anyway to have the mid formula remove the "/" ?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
If your date format default is m/d/y then try Datevalue : =DATEVALUE(A1) and format the result as m/d/yyyy (or whatever).
 
Upvote 0
If your date format default is m/d/y then try Datevalue : =DATEVALUE(A1) and format the result as m/d/yyyy (or whatever).

the problem with the initial data for 1/26/23 - excel is not recognizing it as a date -and in some cases, when it does... it thinks the "23" for year is 1923 rather than 2023 - this is crucial because i also use formula: =text(A1,"DDDD") - but if the year is wrong then the day of the week will also be wrong

so i had to break it up then re-do it for it to recognize it

not sure why its like that
 
Upvote 0
What is your default date format?

mm-dd-yyyy

i've played with the date format - it doesn't work as i'd like

the only thing closest to what i need right now is doing this:

"
However - one thing I noticed is that for my "Day" cell - if its at the beginning of the month it will include the "/" which messes up the whole formula...

so for example
1/26/23

mid(a1,3,2) is showing 26 - perfect

but if the dates is 2/1/23
mid(a1,3,2) shows 1/ "

Is there anyway to have the mid formula remove the "/" ?
 
Upvote 0
Can't think why DATEVALUE doesn't work. What does it return?

The way you are using is very klunky.
Try =SUBSTITUTE(MID(A1,3,2), "/", "")
 
Upvote 0
Solution
Also, what about when the month is 2 digits ?
 
Upvote 0
with your approach

T202301a.xlsm
A
11/26/23
21
326
423
526-Jan-2023
6
1f
Cell Formulas
RangeFormula
A2A2=LEFT(A1,1)
A3A3= MID(A1,3,2)
A4A4=RIGHT(A1,2)
A5A5=DATE("20"&A4,A2,A3)



Try Data Text to Columns date mdy
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top