O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Hour Function

Class

Microsoft.VisualBasic.DateAndTime

Syntax

Hour(timevalue)
timevalue (required; date)

Date variable or literal date

Return Value

An Integer from 0 to 23, specifying the hour of the day

Description

Extracts the hour element from a time expression

Example

The line:

MsgBox(Hour(#1:33:00 PM#))

displays the number 13.

Rules at a Glance

  • Regardless of the time format passed to Hour, the return value will be a whole number between 0 and 23, representing the hour of a 24-hour clock.

  • If time contains Nothing, 0 is returned, so be careful here to check for Nothing.

  • You can also use the DatePart function.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required