DateSerial Function

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


Çfarwdo dite nw muajin e dwshiruar

Return value:



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).

If a date is defined that lies outside of the accepted range, LibreOffice Basic returns an error message.

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.

Error codes:

5 Invalid procedure call


  Sub ExampleDateSerial
  Dim lDate As Long
  Dim sDate As String
      lDate = DateSerial(1964, 4, 9)
      sDate = DateSerial(1964, 4, 9)
      MsgBox lDate ' returns 23476
      MsgBox sDate ' returns 04/09/1964
  End Sub

Please support us!