DATE

Returns a date value based on individual year, month, and day

Usage

DATE(year, month, day)

Parameters

year

(Required) The year. Can be any number and is used as-is.

month

(Required) The month. A number between 1 and 12.

day

(Required) The day. A number between 1 and 31 that forms a valid date with the month and year.

Examples

Example With these variables Result

DATE(year, month, day)

year is 2024
month is 5
day is 28

DATE(2024, 5, 28)

DATE(2024, 1, 12)

(None)

DATE(2024, 1, 12)

DATE(2024, 1, 40)

(None)

ERROR

DATE(2022, 1, -4)

(None)

ERROR

DATE(2022, 1, 21.4)

(None)

ERROR

DATE(-600, 8, 9)

(None)

DATE(-600, 8, 9)

More information

The result you see here looks like the example itself. This is normal. This is the standard format the documentation uses to indicate that a value is a date. This is to distinguish that case from a text that contains a date, which would be "2019-02-04".

Differences with Excel’s DATE function:

  • Numbers with decimals are not accepted
  • Negative months and days are not allowed
  • There are limits on the year, the year -230495 is valid

This function is rarely needed, as other ways of getting a date value are often more practical:

  • use the @DATE_QUESTION to set the variable
  • use a function that converts a text to a date: DATEVALUE(text_date)
  • use a function that returns a date: TODAY() or DATEADD(a_date, 5, "days")

Reminders

A text containing digits is not handled as a number. To have an actual number:

  • use the @NUMBER_QUESTION to set the variable
  • write a numeric value directly in the code without quotes, ex: age >= 18
  • use a function which converts to a number: NUMBER(text_containing_numbers)
  • use a function which returns a number: FIND("world", "hello everybody")

See also