DATE function
Converts a single character string, a set of month, day, and year values, an integer expression, a DATETIME expression, or a DATETIME-TZ expression into a DATE value.
If the DATE function cannot produce a valid date given the specified argument(s), it returns a run-time error.
Syntax
month
day
year
string
A character string containing a date value to convert into a DATE data type. The string value must have the format specified by the Date Format (-d
) startup parameter (the default is mdy). Note that -d sets the display format, not the date storage format, which is fixed. Furthermore, date constants entered in procedures, or as initial values in the Data Dictionary, are always specified in month/day/year format.You do not have to specify separator characters for the month, day, and year components of the date string; however, slashes(/), periods(.), and hyphens(-) are accepted as separator characters.integer-expression
An expression that evaluates to a signed integer value that represents the number of days since the origin of the ABL date data type. Usually this integer is obtained from a previous operation where the date was converted to an integer using the INTEGER(ABL-date
) or INT64(ABL-date
) function.The value of the expression cannot exceed the maximum date value, which is 12/31/32767.Note: The resulting date from the DATE(integer-expression
) function is guaranteed to be a valid ABL date only if theinteger-expression
originated from the INTEGER(ABL-date
) or INT64(ABL-date
) function.datetime-expression
An expression that evaluates to a DATETIME or DATETIME-TZ. The DATE function returns the date portion of thedatetime-expression
as a DATE.Ifdatetime-expression
is a DATETIME-TZ, the DATE function returns the date relative to the time zone of the DATETIME-TZ value. For example, a DATETIME-TZ field,fdt
, is created in London (time zone UTC+00:00) with a value ofMay 5, 2002 at 7:15:03.002 am
. DATE (fdt
) returns05/05/2002
, regardless of the session’s time zone.ExamplesThis procedure reads data from an input file that contains date information from another system stored as character strings without slashes or dashes between month, day, and year. It tries to convert these dates to ABL dates. Some formats cannot be successfully converted. For example:
The following example shows the DATE (
string
) syntax:
This example produces the following output. It produces no date for the first example since spaces are not a valid date separator:
See alsoADD-INTERVAL function, DATE-FORMAT attribute, DATETIME function, DATETIME-TZ function, DAY function, ETIME function, INTERVAL function, ISO-DATE function, MONTH function, MTIME function, NOW function, TIME function, TIMEZONE function, TODAY function, WEEKDAY function, YEAR function, YEAR-OFFSET attribute
OpenEdge Release 10.2B
|