add digits to a CONCATENATE with embedded RIGHT function

blbat

Active Member
Joined
Mar 24, 2010
Messages
338
Office Version
  1. 2016
  2. 2013
The Right function in below formula pulls two digits from a string in G2. G2 = 282110ZOCT08

in the example the last two digits "08" represents the year 2008

=CONCATENATE(LEFT(G2,2),"-",MID(G2,8,3), "-",RIGHT(G2,2))
this results in:
28-OCT-08

I want to add 2000 to just the last segment so it reads 28-OCT-2008.

How can I do that?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
The Right function in below formula pulls two digits from a string in G2. G2 = 282110ZOCT08

in the example the last two digits "08" represents the year 2008

=CONCATENATE(LEFT(G2,2),"-",MID(G2,8,3), "-",RIGHT(G2,2))
this results in:
28-OCT-08

I want to add 2000 to just the last segment so it reads 28-OCT-2008.

How can I do that?
If your value in G2 (or whatever cell) is always 12 characters long (like the single example you posted), you can do it this way...

=UPPER(TEXT(REPLACE(G2,3,5,""),"dd-mmm-yyyy"))

otherwise, this way should work...

=UPPER(TEXT(LEFT(G2,2)&RIGHT(G2,5),"dd-mmm-yyyy"))
 
Last edited:
Upvote 0
If your value in G2 (or whatever cell) is always 12 characters long (like the single example you posted), you can do it this way...

=UPPER(TEXT(REPLACE(G2,3,5,""),"dd-mmm-yyyy"))
Actually, if your values are always 12 characters long, you could use this simpler formula...

=REPLACE(REPLACE(G2,3,5,"-"),7,0,"-20")
 
Upvote 0
Thanks to you both.

Both work.

is there a way to force Excel to see the result as a Date? (without copying and pasting the values back into the column over the formula)

I want to be able to sort by oldest to newest.
 
Upvote 0
Sorry Rick, forgot to answer you- YES, the value is always 12 digits.
 
Upvote 0
is there a way to force Excel to see the result as a Date? (without copying and pasting the values back into the column over the formula)
Sure... normally you would just add 0 to whatever formula you decide on, HOWEVER, since all you want is the real date, then the formula becomes even simpler (since we don't have to provide a formatted text value any more, rather, all we need is text that Excel can recognize is a date when we force it to do so by adding 0 to the formula). This formula will give you a real date as a date serial number so you will have to format the cell you put it in with the date format of your choosing...

=0+REPLACE(G2,3,5,"")

By the way, you should now see the benefit of telling what you actually want to do when you ask a question on this forum instead of assuming how it must be structured and asking how to achieve that structure. As in this case, we may know a simpler way to achieve your ultimate goal from the way you thought it would have to go (just look at how much simpler the formula I posted above is from all the other formulas that everyone here posted trying to get the text to look exactly like you showed us in your first message).
 
Last edited:
Upvote 0
Rick-

Thanks again. and I will consider myself properly chastised on posting questions. Looking at my join date you would think I would know that by now. /doh!

I was so interested in the formula I posted that I never considered posting about the end result I was actually after!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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