DateSerial Function

Returns a Date value for a specified year, month, and day.


DateSerial (ano, mes, d铆a)

Valor de retorno:



Year: Integer expression that indicates a year. All values between 0 and 99 are interpreted as the years 1900-1999. For years that fall outside this range, you must enter all four digits.

Month: Integer expression that indicates the month of the specified year. The accepted range is from 1-12.

Day: Integer expression that indicates the day of the specified month. The accepted range is from 1-31. No error is returned when you enter a non-existing day for a month shorter than 31 days.

The DateSerial function returns the number of days between December 30,1899 and the given date. You can use this function to calculate the difference between two dates.

The DateSerial function returns the data type Variant with VarType 7 (Date). Internally, this value is stored as a Double value, so that when the given date is 1.1.1900, the returned value is 2. Negative values correspond to dates before December 30, 1899 (not inclusive).

Se define unha data non inclu铆da no intervalo reco帽ecido, LibreOffice Basic devolve unha mensaxe de erro.

Whereas you define the DateValue function as a string that contains the date, the DateSerial function evaluates each of the parameters (year, month, day) as separate numeric expressions.

C贸digos de erro

5 Chamada de procedemento incorrecta


  Sub ExampleDateSerial
  Dim lDate As Long
  Dim sDate As String
      lDate = DateSerial(1964, 4, 9)
      sDate = DateSerial(1964, 4, 9)
      msgbox lData REM devolve 23476
      msgbox sDate REM devolve 04/09/1964
  End Sub

Precisamos da s煤a axuda!