Formatting in a formula

Domroy

Board Regular
Joined
Mar 8, 2018
Messages
114
Hi there,

I have a formula that is pulling from other formulas to create a unique number, and the format is coming out incorrectly:

To begin with, I have a date in cell K16. Down in S35, S36 and S37 respectively, I have it pulling the month =month(k16), day =text(day(k16),"dd") and Year =year(k16). Then, I have another formula pulling from those numbers, and I want the numbers to pull in as YYYYMMDD-22937. I have that pulling into the formula by doing =S37&S35&S36&"-"&K8 (where K8 has the 22937). The problem is that it's not formatting the month as two digits. And when I pull the month out as =TEXT(month(K16),"mm") - for all the months below 10, it calls them "01." But for my serial number, it needs to be two digits. So, for example, my date for today would pull out and show as YYYYMDD-22937 - instead of having it show as YYYYMMDD-22937 - with the TWO digit month.

Can anyone help me with this? Also, I've tried formatting the cell as two digits, but, as we all know, that does nothing for when it pulls into the formula. THANK YOU!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi there,

I have a formula that is pulling from other formulas to create a unique number, and the format is coming out incorrectly:

To begin with, I have a date in cell K16. Down in S35, S36 and S37 respectively, I have it pulling the month =month(k16), day =text(day(k16),"dd") and Year =year(k16). Then, I have another formula pulling from those numbers, and I want the numbers to pull in as YYYYMMDD-22937. I have that pulling into the formula by doing =S37&S35&S36&"-"&K8 (where K8 has the 22937). The problem is that it's not formatting the month as two digits. And when I pull the month out as =TEXT(month(K16),"mm") - for all the months below 10, it calls them "01." But for my serial number, it needs to be two digits. So, for example, my date for today would pull out and show as YYYYMDD-22937 - instead of having it show as YYYYMMDD-22937 - with the TWO digit month.

Can anyone help me with this? Also, I've tried formatting the cell as two digits, but, as we all know, that does nothing for when it pulls into the formula. THANK YOU!
Ugh! One extra Google Search answered my question. It's =text(k16,"mm")
 
Upvote 0
Solution
Hi,

Use

Excel Formula:
=TEXT(MONTH(K16),"00")

What you posted won't work. (I mean in your OP)
 
Last edited:
Upvote 0
Also, You don't have to extract the different parts of the K16 Date into S35, S36, S37, unless you want to for some reason.
You can just do the entire conversion with 1 single cell formula:

Book3.xlsx
ABCD
13/9/20222293720220309-22937
Sheet1047
Cell Formulas
RangeFormula
D1D1=TEXT(A1,"yyyymmdd")&"-"&B1
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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