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

Embedding Your Phone Number in a Document

One way you can designate your responsibility for a document is to add your phone number to it. There is no need to add your ...

Discover More

Specifying How Clicking Works

Do you want to fundamentally change how Windows responds to mouse clicking? You can do so by following the steps outlined in ...

Discover More

Stopping a Checked Box from being Unchecked

When creating user forms for use in Excel, you are provided with a range of controls you can add, including check boxes. If ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Calculating Time Differences between Two Machines

Want to know how much of a time difference there is between your machine and a different machine? This tip provides some ...

Discover More

Displaying Negative Times

Excel allows you to perform math using times as operands. If you subtract a later time from an earlier time, you should end ...

Discover More

How Excel Stores Dates and Times

Excel stores dates and times internally using what is called a serial number. This tip explains how that serial number is ...

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. Maximum image size is 8Mpixels. 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 5 + 0?

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.