DateAndTime.Hour(DateTime) 方法

定義

回傳一個從0到23的整數值,代表一天中的時段。

public:
 static int Hour(DateTime TimeValue);
public static int Hour(DateTime TimeValue);
static member Hour : DateTime -> int
Public Function Hour (TimeValue As DateTime) As Integer

參數

TimeValue
DateTime

必須的。 一個 Date 你想從中提取小時的數值。

傳回

一個從0到23的整數值,代表一天中的時段。

範例

此範例使用函 Hour 數取得指定時間的整點。 在開發環境中,時間字面值會以短時間格式顯示,使用程式碼的區域設定。

Dim someTime As Date
Dim someHour As Integer
someTime = #4:35:17 PM#
someHour = Hour(someTime)
' someHour now contains 16.

備註

你也可以打電話 DatePart 並指定 DateInterval.Hour 論點的時間 Interval

適用於

另請參閱