
- VBA Tutorial
- VBA - Home
- VBA - Overview
- VBA - Excel Macros
- VBA - Excel Terms
- VBA - Macro Comments
- VBA - Message Box
- VBA - Input Box
- VBA - Variables
- VBA - Constants
- VBA - Operators
- VBA - Decisions
- VBA - Loops
- VBA - Strings
- VBA - Date and Time
- VBA - Arrays
- VBA - Functions
- VBA - Sub Procedure
- VBA - Events
- VBA - Error Handling
- VBA - Excel Objects
- VBA - Text Files
- VBA - Programming Charts
- VBA - Userforms
- VBA Useful Resources
- VBA - Quick Guide
- VBA - Useful Resources
- VBA - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
VBA - Hour Function
The Hour Function returns a number between 0 and 23 that represents the hour of the day for the specified time stamp.
Syntax
Hour(time)
Example
Add a button and add the following function.
Private Sub Constant_demo_Click() msgbox("Line 1: " & Hour("3:13:45 PM")) msgbox("Line 2: " & Hour("23:13:45")) msgbox("Line 3: " & Hour("2:20 PM")) End Sub
When you execute the above function, it produces the following output.
Line 1: 15 Line 2: 23 Line 3: 14
vba_date_time.htm
Advertisements