Help with Formula Year, Month and date

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,079
Office Version
  1. 365
Platform
  1. Windows
HI,
I was trying to put the right formula together to change Month, Day, Year to Year, Month and day.

Example in C1 I have 120721. Need to change it to 211207 - Year, Month and day
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
How about
Excel Formula:
=REPLACE(LEFT(C1,4),1,0,RIGHT(C1,2))+0
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
If you don't mind me asking, what is the +0 for? I tested without and got the same result. Still trying to understand how Replace in Excel works!
 
Upvote 0
The replace function returns a text string & the +0 converts that back to a number.
 
Upvote 0
Thanks for responding and teaching. Would that be the same (but perhaps easier) than
VALUE(REPLACE(LEFT(C1,4),1,0,RIGHT(C1,2)))
Formatting either to a date just happens to return the same date.
 
Upvote 0
Another way (though I am not sure the OP needs conversion to number?)
Excel Formula:
=--MID(C1&C1,5,6)
 
Upvote 0
Thanks for responding and teaching. Would that be the same (but perhaps easier) than
VALUE(REPLACE(LEFT(C1,4),1,0,RIGHT(C1,2)))
Formatting either to a date just happens to return the same date.

Hi,

Yes, that would be the same, just a different method, the following all do the same:

Book3.xlsx
CD
1120721211207
2211207
3211207
4211207
5211207
6211207
Sheet1011
Cell Formulas
RangeFormula
D1D1=REPLACE(LEFT(C1,4),1,0,RIGHT(C1,2))+0
D2D2=0+REPLACE(LEFT(C1,4),1,0,RIGHT(C1,2))
D3D3=VALUE(REPLACE(LEFT(C1,4),1,0,RIGHT(C1,2)))
D4D4=REPLACE(LEFT(C1,4),1,0,RIGHT(C1,2))*1
D5D5=1*REPLACE(LEFT(C1,4),1,0,RIGHT(C1,2))
D6D6=--REPLACE(LEFT(C1,4),1,0,RIGHT(C1,2))
 
Upvote 0
Thanks. Next task is to figure how the double minus signs (which coerce true/false to 1/0?) applies here. I'm imagining it has the same effect as adding 0 to a string. Interesting that in Access, 0 is false, but -1 is True.
 
Upvote 0

Forum statistics

Threads
1,215,233
Messages
6,123,771
Members
449,122
Latest member
sampak88

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