Skip to content

DateSerial - Built-in Date & Time Function

Purpose

DateSerial returns a date from the specified year, month, and day.

Syntax

DateSerial(year, month, day)

Arguments

Argument Required Description
year Yes Any valid integer expression containing the year
month Yes Any valid integer expression containing the month
day Yes Any valid integer expression containing the day

Returns

DateTime

See also

Example

Dim dVar

// Constructs a new date by subtracting 10 years from the static year 1990
Let dVar = DateSerial(1990 - 10, 5, 31)

Return dVar // returns 31 May, 1980

Notes

  • When one or more of the arguments cannot be converted to an integer, a runtime error is generated.
  • DateSerial returns a datetime with the time portion set to midnight.
  • The minimum year for a date is 1601.
  • For year (the year), values between 0 and 99 are interpreted as the years 1900-1999.
  • The day part of the expression must be in the range of 1-31. Passing less than 1 or more than 31 results in an invalid date and fallback to December 30, 1899.
  • When the day part is 29 and the month is 2 and the year is not a leap year, the next day is returned.
  • If a test against the DataFlex dummy zero date is to be performed use the IsDummyZeroDate function.