
Tips.Net > WordTips Home > Creating Macros > Dates and Times > Determining the Day of the Month
Summary: Need to figure out the day of the month (1 through 31)? This code will do the trick either in VBA or WordBasic. (This tip works with Microsoft Word 6, Word 95, Word 97, Word 2000, Word 2002, and Word 2003.)
When creating macros in either WordBasic or 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(Now())
The Day function returns an integer value representing the day of the month of whatever date you provide. In this example, the Now function represents today's date, and so Day returns today's day of the month. The Day function, again, will work in both WordBasic and VBA.
Tip #807 applies to Microsoft Word versions: 6 95 97 2000 2002 2003
Find and Replace Almost Anything! An invaluable resource for learning how to harness the full power of Word's search and replace capabilities. You'll discover everything you need in order to master all the intricacies of finding and replacing elements of your document, including the super-powerful ?wildcard searches? available in Word.
Check out WordTips: Find and Replace today!
Discover how to use Word's mail merge tool to create your own custom documents in just minutes. Great e-book answers all your questions. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips