Re-format a string & make the last 4 digits as "Year"

mac_junior

New Member
Joined
Oct 2, 2018
Messages
4
Hello

I have a string : ABC02102018 at cell A1. I need to make it looks like ABC 02/10/2018. I wrote =CONCATENATE(MID(A1,1,3), " ",MID(A1,4,2), "/",MID(A1,6,2), "/",MID(A1,8,4)).
Now I would like to make my last 4 digits of string (ie.2018) into YEAR format. I tried by using year() function, but it came out to 1905 instead of 2018. Does it have a way to solve it?

Thanks and regards,
John
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
What do you mean by year format? 2018 is a year format to my mind.
 
Upvote 0
Yes I agree but 2018 just look like year format to us. When I put year(2018). I will output 1905. So, if I need to do some sorting in the future, it may go wrong.
Meanwhile, I was wondering if it can be achieved? I mean can I format part of the string which contain characters and digits.
Thanks again
 
Upvote 0
2018 is already a year number. Why would you use YEAR(2018)? The YEAR function returns a year number from a date, so it expects a date value, not just a year number. Since Excel stores dates as the number of days since 31/12/1899, YEAR(2018) is the equivalent of YEAR(10/07/1905) which is why you get 1905 back.

You can certainly format parts of a string, but it's not clear to me what formatting you are trying to apply.
 
Last edited:
Upvote 0
2018 is already a year number. Why would you use YEAR(2018)? The YEAR function returns a year number from a date, so it expects a date value, not just a year number. Since Excel stores dates as the number of days since 31/12/1899, YEAR(2018) is the equivalent of YEAR(10/07/1905) which is why you get 1905 back.

You can certainly format parts of a string, but it's not clear to me what formatting you are trying to apply.

Rory, thank you very much. I will try to work use it without using format(2018).
 
Upvote 0

Forum statistics

Threads
1,224,746
Messages
6,180,705
Members
452,994
Latest member
Janick

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