Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Determining the Day of the Month.

Determining the Day of the Month

by Allen Wyatt
(last updated May 24, 2014)

7

When creating macros in VBA, you may have a need to know the specific day of the month represented by a particular date. For instance, you may want to determine the day of the month on which the macro is being executed. The following code will do the trick:

iDay = Day(Date)

The Day function returns an integer value representing the day of the month of whatever date you provide. In this example, the Date function represents today's date, and so Day returns today's day of the month.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2502) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Determining the Day of the Month.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Changing the Footnote Continuation Separator

When you add a really long footnote to a document, it could be that the entire footnote might not fit on the page where the ...

Discover More

Decreasing a Paragraph's Indent

When formatting your document, you often have need to indent paragraphs. If you later want to decrease the indent used on ...

Discover More

Putting a Macro Name on the Quick Access Toolbar

In older versions of Word you could customize the program so that either icons or text (or both) could appear on the ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (menu)

Tombstone Date Math

Doing math with dates is easy in Excel. Doing math with old dates—such as those you routinely encounter in ...

Discover More

Backwards Date Parsing

Enter information into a worksheet, and you come to anticipate (and count on) how Excel will interpret that information and ...

Discover More

Setting a Default Date Format

Enter a date into a cell, and Excel allows you to format that date in a variety of ways. Don't see the date format you want? ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 5?

2014-05-30 09:39:04

Barry

@ Micky, Sorry I still disagree.

Just to wrap this up in case to ensure other readers aren't mislead.

Using Today() or Now() leaves the underlying value as a date serial number e,g, using Now()today (30th May2014) would give a value of 41789, this can be displayed as 30 by using the cell formatting but should you for whatever reason multiply this by, say, 2 you will get a totally different from using the Day(Now()) formula and performing the same calculation.


2014-05-29 15:40:39

Michael (Micky) Avidan

@Barry,
Disagreeing is good but not good enough.
The tip was refering to (quote): "returning an integer(!) value representing the day of the month of whatever date you provide" (end of quote).
There is no difference between NOW() and TODAY() as far as returning the day of the provided date.
I rest my case.

Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2014)
ISRAEL


2014-05-29 13:14:09

Barry

Of course if you do just want a numeric value on a worksheet then the formula:

=DAY(NOW())

is by far the easiest solution.


2014-05-25 12:11:06

Barry

@ Micky,

For once, I have to disagree with your second sentence; setting the display format doesn't change the underlying value which will be the full date serial number and therefore performing any mathematical function on this expecting it to be just the day of the month with give an incorrect result.

You're correct in you're third sentence assuming the User wants a value rather than text. If the User wants a value then using the VALUE function on the result will convert the text to a number.


2014-05-24 15:22:40

Michael (Micky) Avidan

@Barry,
Ignore the first sentence, in my post, regarding the helper-column.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2014)
ISRAEL


2014-05-24 11:53:25

Michael (Micky) Avidan

@@Barry,
To my opinion it is a waste to use an Helper column.
The same can be achieved by putting: =NOW() in the cell and format it with one of the day formats.
(dd / ddd / dddd)
In addition - the result of your suggestion is Pure Text and as such no calculations can be perfomed on it.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2014)
ISRAEL


2014-05-24 05:06:05

Barry

If you only want this on a worksheet then you can use the formula:

=TEXT(NOW(),"d"))

using "dd" will include a leading zero for days 1-9;
"ddd" will give a short day name e.g. Mon
"dddd" will give the full day name e.g. Monday

The same is true for months just substitute "m" for "d"


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.