DateSerial Function

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

Syntax:


DateSerial (năm, tháng, ngày)

Return value:

Ngày

Parameters:

Year: biểu thức số nguyên mà ngụ ý một năm. Tất cả các giá trị nằm giữa 0 và 99 được đọc là năm 1900-1999. Đối với nằm ở ngoại phạm vi này, bạn cần phải nhập cả bốn chữ số.

Tháng: biểu thức số nguyên mà ngụ ý tháng của năm đã ghi rõ. Phạm vi hợp lệ là 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.

Hàm DateSerial trả về số ngày nằm giữa ngày 30, tháng 12/1899 và ngày đã cho. Bạn có thể sử dụng hàm này để tính hiệu của hai ngày tháng.

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 1900-01-01, the returned value is 2. Negative values correspond to dates before December 30, 1899 (not inclusive).

Nếu bạn xác định một ngày tháng nằm ở ngoại phạm vi hợp lệ, LibreOffice Basic trả về một thông điệp lỗi.

Dù bạn xác định hàm DateValue dưới dạng một chuỗi chứa ngày tháng, hàm DateSerial ước tính mỗi thành phần (năm, tháng, ngày) là một biểu thức thuộc số riêng.

Error codes:

5 Sai gọi thủ tục

Example:


  Sub ExampleDateSerial
  Dim lDate As Long
  Dim sDate As String
      lDate = DateSerial(1964, 4, 9)
      sDate = DateSerial(1964, 4, 9)
      msgbox lDate REM returns 23476
      MsgBox sDate ' returns 1964-04-09 in ISO 8601 format
  End Sub

Please support us!