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.
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:
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.
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!
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 MoreDo 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 MoreAn 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 MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
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")
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.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2026 Sharon Parq Associates, Inc.
Comments