DateValue Function [Runtime]

From LibreOffice Help
Jump to: navigation, search

Returns a date value from a date string. The date string is a complete date in a single numeric value. You can also use this serial number to determine the difference between two dates.

Syntax:

DateValue [(date)]

Return value:

Date

Parameters:

Date: String expression that contains the date that you want to calculate. The date can be specified in almost any format.

You can use this function to convert a date that occurs between December 1, 1582 and December 31, 9999 into a single integer value. You can then use this value to calculate the difference between two dates. If the date argument lies outside the acceptable range, LibreOffice Basic returns an error message.

In contrast to the DateSerial function that passes years, months, and days as separate numeric values, the DateValue function passes the date using the format "month.[,]day.[,]year".

You can set the locale used for controlling the formatting numbers, dates and currencies in LibreOffice Basic in Tools - Options - Language Settings - Languages. In Basic format codes, the decimal point (.) is always used as placeholder for the decimal separator defined in your locale and will be replaced by the corresponding character.

The same applies to the locale settings for date, time and currency formats. The Basic format code will be interpreted and displayed according to your locale setting.

Error Codes

5 Invalid procedure call

Example:

Sub ExampleDateValue

msgbox DateValue("12/02/1997")

end sub