DATE

The DATE data type stores calendar dates with a Year/Month/Day representation.

Syntax

DATE

Usage

Storage of DATE variables is based on a 4 byte integer representing the number of days since 1899/12/31.

The value range is from 0001-01-1 (-693594) to 9999-12-31 (2958464) .

Because DATE values are stored as integers, you can use them in arithmetic cursor: the difference of two dates returns the number of days. This is possible (and portable) with language arithmetic operators, but should be avoided in SQL statements, because not all databases support integer-based date arithmetic.

Data conversions, input and display of DATE values are ruled by environment settings, such as the DBDATE and DBCENTURY enviroment variables.

Several built-in functions and constants are available such as MDY() and TODAY.

DATE variables are initialized to zero (=1899/12/31) in functions, modules and globals.

Integers can represent dates as a number of days starting from 1899/12/31, and can be assigned to dates. It is not recommended that you directly assign integers to dates, however, for source code readability.

As Date-to-String conversion is based on an environment setting, it is not recommended that you hard code strings representing Dates.

MAIN
  DEFINE d DATE
  LET d = TODAY
  DISPLAY d, "  ", d+100
END MAIN