Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Determining the Hour of the Day.

Determining the Hour of the Day

Written by Allen Wyatt (last updated August 1, 2026)

1

If you are writing macros in VBA, you may have a need to determine the hour represented by a particular date and time value. For instance, you might want to know the hour of the day in which the macro is running. You can ascertain this information by using the HOUR function, as follows:

iThisHour = Hour(Now())

When executed, iThisHour will be equal to the current hour number, which ranges from 0 to 23. Notice that this example uses the Now() function. If you want to determine the hour number for a different date and time value, simply substitute that value in place of the Now() function.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11880) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. You can find a version of this tip for the older menu interface of Word here: Determining the Hour of the Day.

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

Getting Rid of Blank Labels in a Filtered Merge

If you are filtering a mail merge in Excel, and you get blank labels in the printout in Word, chances are good that ...

Discover More

Setting Consistent Column Widths in Multiple Tables

Tables are great for organizing and presenting information in a document. If you have a document containing multiple ...

Discover More

Automatically Referencing Info Entered in a Table

Tables are a great way to organize information in a document. At some point you may want a cell in a table to contain the ...

Discover More

Do More in Less Time! An easy-to-understand guide to the more advanced features available in the Microsoft 365 version of Word. Enhance the quality of your documents and boost productivity in any field with this in-depth resource. Complete your Word-related tasks more efficiently as you unlock lesser-known tools and learn to quickly access the features you need. Check out Microsoft 365 Word For Professionals For Dummies today!

More WordTips (ribbon)

Changing the Default Drive

Macros can be used to read and write all sorts of files. If those files are on a different drive than the current one, ...

Discover More

Copying a Range of Pages in a Macro

Do you need to copy, within a macro, a range of pages? Because pages can be so fluid in Word, this can be a bit tricky. ...

Discover More

Quickly Clearing Array Contents

An array of variables is a powerful element of VBA programming. If you want to clear what is stored in an array, here's a ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. 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 eight minus 1?

2026-08-01 08:13:59

jamies

Maybe add abilities to the code :
To set the time as GMT
And not to include daylight saving adjustment in that time
Have the time set as an offset from the local time - such as for the time into a shift session ( maybe more than 24 hours ?)
Have time elapsed work around the local change for DST
UTC
Common Era (CE)
Holocene Human Era (HE) calendar
Muslim calendar) (AH)

OK, ignore the occasional 61st second in the last minute of the last day of the year, or June !

And leave the Vedic, Gregorian, Jewish, Islamic, Indian, Chinese, and Julian Calendars, and other complex systems, including Astronomical ones to those needing to use them.

Universal Time (UT): Solar time based on the rotation of Earth, adjusted to the prime meridian at Greenwich.
Sidereal Time: Time measured by the daily motion of stars relative to the vernal equinox rather than the Sun.
Julian Date (JD): A continuous count of days and fractions of a day since noon on January 1, 4712 BCE,
used to avoid calendar date shifts.
Ephemeris Time
Dynamical Time:
Uniform time

Just - when dealing with dates - remember, while the UTC is widely understood, and accepted for international and foreign communication, just because the boss expects that, doesn't mean it is acceptable to use it in all cases, or locations.

Indeed there is the 360 day year - and 12 x 30 day months - the exclusion of some "holidays", or "Holy days" from possible business calendars

And - from bankers - actions to be performed on the same day of every month - when first done on the 31st day of a month, and is a shift 8 hours if from midnight to 8 a,m - when the clocks go back - leaving the logs of entries and computer actions with multiple streams of timestamps for the repeated hour !

Oh the confusion possible when dealing with dates and times and government decrees that change dates, or times for processes, and historical references -
without even the Excel 1900 and 1904 and 29th February 1900 confusion, let alone Windows built in, but alterable assumption that 24/3/25 is 24th March 2025, and 26/4/40 is 26th April 1940
and language/ country formatting expectations

or - currency, or monthnames
=TEXT(A1, "[$-fr-FR]mmm")

or the LCID coding
TEXT(A1;"[$-040C]mmm")


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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.