bottom
Great WordTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > WordTips Home > Creating Macros > Dates and Times > Determining the Month of the Year

Determining the Month of the Year

Summary: Need to figure out the month of the year (1 through 12)? 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 month of the year, as represented by a particular date. For instance, you may want to determine the month in which the macro is being executed. The following code will do the trick:

iMonth = Month(Date())

The Month function returns an integer value representing the numeric month of whatever date you provide. In this example, the Date function represents today's date, and so Month returns the current month, as a value ranging from 1 to 12. The Month function, again, will work in both WordBasic and VBA.

Tip #815 applies to Microsoft Word versions: 6 | 95 | 97 | 2000 | 2002 | 2003


Save Time! WordTips has been published weekly since early 1997. Past issues are available in convenient WordTips archives. Have your own enhanced archive of WordTips at your fingertips, available to use at any time!
 
Check out WordTips Archives today!

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Vital News Home

WordTips FAQ
WordTips Premium

Learn Access Now

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

Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)