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.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!
Formulas created in a macro have a specific order in which operations are performed. This is known as precedence, as ...
Discover MoreWant to give your macros a different name than they currently use? It's easy to do using the VBA Editor as described here.
Discover MoreWriting macros often involves selecting different parts of your document so that some sort of processing can be ...
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