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

An Unruly Ruler

Does the ruler in Word seem to have a mind of its own? If you have problems understanding why the ruler behaves as it does, ...

Discover More

Setting the Starting Line Number

You are not limited to starting the line numbering in a document with 1. You can, instead, start the numbering at any other ...

Discover More

MS-DOS with Line Breaks Format in Word 2002 and Word 2003

Finding the built in functionality in Word 2002 & 2003 for saving your document as a MS-DOS format.

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)

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

Converting UTC Times to Local Times

Dates and times are often standardized on UTC time, which is analogous to GMT times. How to convert such times to your local ...

Discover More

Finding the Previous Work Day

Excel has a number of functions that are available as an add-on in the Analysis ToolPak. One of these functions allows you to ...

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 for this tip:

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 three minus 1?

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.

Links and Sharing