The Excel HOUR Function
Basic DescriptionThe Excel HOUR function returns an integer representing the hour component of a supplied Excel time. The format of the function is:HOUR( time )
where the time argument can be supplied as a time value or a reference to a cell containing a time. Note that, if the time argument contains a date and time, the Hour function ignores the date part of the argument. ExamplesThe following spreadsheet shows the Excel Hour function applied to several different supplied times. The spreadsheet on the left shows the format of the function and the spreadsheet on the right shows the results.
Note that, in the above examples, the time shown in cell A4 is actually a whole day plus the time 05:11:22. Therefore, when supplied with this time value, the Hour function ignores the full day and simply returns the hour value 5. The HOUR Function In VBAThe HOUR function is also a built-in function in VBA (used for writing Excel Macros). Within VBA, the function takes exactly the same format as when used in an Excel spreadsheet: HOUR( time )
For example:
After running the above snippet of VBA code, the variable 'HourNum' holds the value 17, which is the hour component of the time "17:56:33". |
||||||
|
|
||||||
Copyright © 2008-2010 ExcelFunctions.net |