CDate Function [Runtime]

From LibreOffice Help
Jump to: navigation, search

Converts any string or numeric expression to a date value.

Syntax:

CDate (Expression)

Return value:

Date

Parameters:

Expression: Any string or numeric expression that you want to convert.

When you convert a string expression, the date and time must be entered in the format MM.DD.YYYY HH.MM.SS, as defined by the DateValue and TimeValue function conventions. 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.

Error Codes

5 Invalid procedure call

Example:

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