Date | DATE
Syntax
DATE( [input], [default = Date("1970-01-01T00:00:00.000Z")] )
Parameters
input
Input may be either a string representation of the date time or it may be a numerical representation of the number of seconds since the epoch (1970-01-01T00:00:00.000Z = 0).
default optional
If input cannot be converted to a date value, default is
returned. default may be any value, but the default value will be coerced into a date
value.
Return Value
The result of the input being converted to a date value.Description
The input will be coerced into a date type value. The input will be returned unmodified if the input is already a date value. The input may conform to a wide variety of string date formats.Examples
Non date inputs will return the default value.DATE() # returns DATE("1970-01-01T00:00:00.000Z")
DATE([1, 2, 3]) # returns DATE("1970-01-01T00:00:00.000Z")
DATE(null) # returns DATE("1970-01-01T00:00:00.000Z")
DATE("test") # returns DATE("1970-01-01T00:00:00.000Z")
Text and string values that can be parsed as a date will return a date value.DATE(1577836800) # returns DATE("2020-01-01T00:00:00.000Z")
DATE("2020-01-01") # returns DATE("2020-01-01T00:00:00.000Z")
DATE("1/1/2020") # returns DATE("2020-01-01T00:00:00.000Z")
DATE(null, "1/1/2020") # returns DATE("2020-01-01T00:00:00.000Z")
If the default value is not a valid date string or number, the default of DATE(0) is used.DATE(null, "test") # returns DATE("1970-01-01T00:00:00.000Z")