Contenido
Índice 🔎︎

# Función DateValue

Returns a Date object from a string representing a date.

The returned object is represented internally as a single numeric value corresponding to the specified date. This value can be used to calculate the number of days between two dates.

### Sintaxis:

      DateValue(date As String)

### Parámetros:

date: A string that contains the date that will be converted to a Date object.

The string passed to DateValue must be expressed in one of the date formats defined by your locale setting (see LibreOfficeDev - PreferencesTools - Options - Language Settings - Languages) or using the ISO date format "yyyy-mm-dd" (year, month and day separated by hyphens).

### Valor de retorno:

Date.

### Códigos de error:

5 Llamada a procedimiento no válida

### Ejemplo:

      Sub ExampleDateValue
          Dim aDate As Date
          aDate = DateValue("2021-12-20")
          ' Devuelve la fecha regionalizada
          MsgBox aDate
          '  Extrae el año, el mes y el día del objeto Date
          MsgBox Year(aDate)
          MsgBox Month(aDate)
          MsgBox Day(aDate)
          ' Devuelve el valor numérico correspondiente a la fecha (como entero de tipo largo)
          MsgBox CLng(aDate)
      End Sub

Temas relacionados

Función DateSerial