CDate Function

將任意字串型表示式或數值型表示式轉換為日期值。

語法


CDate (Expression)

傳回值類型

日期

參數:

Expression:要轉換的任意字串型表示式或數值型表示式。

When you convert a string expression, the date and time must be entered either in one of the date acceptance patterns defined for your locale setting (see - Language Settings - Languages) or in ISO date format (momentarily, only the ISO format with hyphens, e.g. "2012-12-31" is accepted). In numeric expressions, values to the left of the decimal represent the date, beginning from December 31, 1899. Values to the right of the decimal represent the time.

錯誤代碼:

5 無效的程序呼叫

示例:


Sub ExampleCDate
    MsgBox cDate(1000.25) ' 09.26.1902 06:00:00
    MsgBox cDate(1001.26) ' 09.27.1902 06:14:24
End Sub

Please support us!