
Tips.Net > WordTips Home > Macros > VBA Examples > Determining the Day of the Year
Summary: Need to figure out the day of the year (1 through 366)? This VBA code will do the trick. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)
If you are writing macros in VBA, you may have a need to determine the current day of the year. For instance, you might want to know that February 21 is the 52 day of the year. VBA includes a handy function that allows you to quickly and easily determine the current day of the year:
iThisDay = DatePart("y", Date)
When executed, iThisDay will be equal to the current day number. Notice that this example uses the Date function. If you want to determine the day number for a different date, simply substitute that date in place of the Date function.
Tip #817 applies to Microsoft Word versions: 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!
It doesn't matter if you are a beginner or expert, the WordTips archives are the fastest way to improved productivity. (more information...)
Ask a Word Question
Make a Comment
Bugs and Pests Tips
ExcelTips
Family Tips
Health Tips
Home Tips
Organizing Tips
WordTips