Date

This keyword declares a date variable where the value is within the range from [1/1/1600] to [31/12/9999], plus a null date [0/0/0].

Syntax

Local Date NAMELocal Date NAME(DIMENSIONS)Variable Date NAME(DIMENSIONS)Value Date NAME(DIMENSIONS)Const Date NAME(DIMENSIONS)

Several variable declarations can be done on the same line, separated by a comma.

Local declarations create the variables in the current local variable class that is not seen by nested or calling subprograms. The Call / Subprog and func / Funprog insulate the local variables as well as the calls of method by fmet.

Const, Variable, and Value declarations state the arguments sent by a Call, func, or fmet. With these syntaxes, the dimensions and the index ranges can be omitted wherever the parentheses are present. The dimension and index ranges are defined by the calling program.

Example

# Direct declarationsLocal Date TODAY, TOMORROW, YESTERDAY : # Local date variablesLocal Date PERIOD_LIMITS(1..60) : # An array of 60 dates values# A sub-program sending dates and returning a resultFunprog SEND_DATES(MYDATES)Variable Date MYDATES(,) : # A 2 dimensions matrix of dates is sent as reference...End SEND_STATUS# A sub-program storing datesSubprog STORE_VALUES(APPOINTMENT_DATES)Value Date APPOINTMENT_DATES(1..5) : # An array of 5 elements is sent (a copy is done when passing the arguments)...End

Operators and dates

The standard arithmetic operators can be used to compare dates. These operators include >, >=, =<, <, +, -, += and -=.
Local Date TEST_DATELocal Char TEST_CHARTEST_DATE = [31/01/2014] # TEST_DATE = 20140131 (Date format)TEST_CHAR = TEST_DATE# TEST_CHAR = "20140131" (String format - implicit data type conversion)TEST_DATE > date$ # Is 20140131 > date$ ? Either true or false depending on date# All other comparison operators workTEST_DATE += 50# Add 50 days to TEST_DATE (Note upper limit=[31/12/9999])TEST_DATE -= 75# Subtract 75 days from TEST_DATE (Note lower limit=[01/01/1600])TEST_DATE = "140131" # Convert string to date using adxdcs yearTEST_CHAR = num$(TEST_DATE) # TEST_CHAR = "[31/01/2014]"

Functions and dates

Implicit data type conversion

The date data type will implicitly convert two string formats to a valid date. The two string formats are "YYYYMMDD" and "YYMMDD". In the format "YYMMDD" that the pivot year variable adxdcs is used to determine the century.

<pre><code>Local Date MY_DATE # Declare dateMY_DATE = "20170630"# String YYYYMMDD dateMY_DATE = "170630" # String YYMMDD date</pre></code>

Both conversions translate to date 20170630 as the pivot year adxdcs is equal to 1950. This means all dates in YYMMDD format with YY equal to or greater than 50 translate to years starting in 1900 and YY less than 50 translates to years starting in 2000 during the data type conversion.

See also

Global, Local, Variable, Value, Const, Tinyint, Shortint, Integer, Float, Double, Decimal, Char, Clbfile, Blbfile, Uuident, Datetime, Instance.