Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

傳回包含時間的 Variant (Date)。

語法

TimeValue ( time )

引數 的必要 時間 通常是代表從上午 0:00:00 到上午 12:00:0 (0 ) 到 23:59:59 (11:59:59.) 的時間 字串運算式 , 不過, 時間 也可以是任何代表該範圍內時間的 運算式 。 如果 time 包含 Null,就會傳回 Null

註解

您可以使用 12 小時或 24 小時制輸入有效的時間。 例如, "2:24PM""14:24" 都是有效的 時間 自變數。

如果 time 自變數包含日期資訊, TimeValue 不會傳回。 不過,如果 時間 包含無效的日期資訊,則會發生錯誤。

查詢範例

Expression

結果​​

SELECT TimeValue ([DateTime]) AS Expr1 FROM ProductSales;

傳回沒有日期資訊之字段 「DateTime」 的時間值,並顯示在表達式1 欄中。

SELECT TimeValue ([DateTime]) AS JustTime FROM ProductSales;

傳回沒有日期資訊之字段 「DateTime」 的時間值,並顯示在 JustTime 欄中。

VBA 範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例使用 TimeValue 函數將字串轉換為時間。 您也可以使用日期常值,直接將時間指派給 VariantDate 變數,例如 MyTime = #4:35:17 PM#。

Dim MyTime
MyTime = TimeValue("4:35:17 PM") ' Return a time.

選擇正確的日期函數

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×