How to convert date from a hyphen "-" to an underscore "_"

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
Office Version
  1. 2019
Platform
  1. Windows
How do I convert a formula that outputs month number and year joined together with each other using a hyphen and change that into underscore. The formula I have is important because when last month of the year is reached, the plus 1 then gives me next year's date e.g. 01-2022

A3 = TEXT(DATE(A2,A1+1,1),"mm-yyyy")

A1 = 01
A2 = 2021

Current output = 01-2021

Desired output = 01_2021

Thanks.
 

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
The above response will be fine for display purposes but won't actually be date.

Instead try;

A3= TEXT(DATE(A2,A1+1,1),"mm\_yyyy")

Without the slash Excel turns _ into a space in text formats for some reason (despite spaces being completely acceptable in formats!)
 
Upvote 0
Solution

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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