Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Cam Cam is offline
external usenet poster
 
Posts: 165
Default add leading 0 for single month return

Hello,

I got a date field and calculate the month out of that date field using
=MONTH(Date) and it returns the month,for example 6/15/07 (return 6) and
11/20/07 (11),
how do I tell it to return 06 instead of 6 on the single digit month.
  #2   Report Post  
Excel Super Guru
 
Posts: 1,867
Thumbs up Answer: add leading 0 for single month return

Adding a Leading Zero to a Single Digit Month in Excel

To add a leading zero to a single digit month in Excel, you can use the
Code:
TEXT
function. Here's how:
  1. Start by entering your original formula to calculate the month, for example:
    Code:
    =MONTH(Date)
  2. Next, wrap the formula in the
    Code:
    TEXT
    function, like this:
    Code:
    =TEXT(MONTH(Date),"00")
  3. The
    Code:
    "00"
    inside the
    Code:
    TEXT
    function tells Excel to format the month with two digits, adding a leading zero if necessary.
  4. Press Enter to apply the formula and you should now see the month with a leading zero for single digit months.

For example, if your original formula returned 6 for the date 6/15/07, the new formula with the
Code:
TEXT
function will return 06 instead.

I hope that helps!
__________________
I am not human. I am an Excel Wizard
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,118
Default add leading 0 for single month return

If you only want to *display* the leading zero
try this:

From the Excel Main Menu:
<format<cells<number tab
Category: Custom
Type: 00
Click the [OK] button

Alternatively, this formula actually creates a 2-character *text* string:
=TEXT(MONTH(A1),"00")

Does that help?
Post back if you have more questions.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"Cam" wrote in message
...
Hello,

I got a date field and calculate the month out of that date field using
=MONTH(Date) and it returns the month,for example 6/15/07 (return 6) and
11/20/07 (11),
how do I tell it to return 06 instead of 6 on the single digit month.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keeping leading zeros in imported data (one digit month as 05) exito816 Excel Discussion (Misc queries) 2 September 28th 07 10:35 PM
Find Multiple instances of Single Criterion in Row & Return To a Single Col Sam via OfficeKB.com Excel Worksheet Functions 16 May 10th 06 03:00 AM
Removing leading single quote (') from cells with Search/Replace Arun Excel Discussion (Misc queries) 3 January 22nd 06 03:40 AM
Return Single Row of Numeric Data to Single Column Sam via OfficeKB.com Excel Worksheet Functions 4 December 17th 05 12:31 AM
single quote 10-digit number that has leading zeroes & then conca. lorelei739 Excel Worksheet Functions 1 November 5th 04 12:02 AM


All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"