Language basics / Data types |
The DATE data type stores calendar dates with a Year/Month/Day representation.
DATE
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) .
DATE variables are initialized to zero (=1899/12/31) in functions, modules and globals.
Several built-in functions and operators specific to the DATE type are available, such as MDY() and TODAY. For more details, see Date and time operators.
Data type conversions, input and display of DATE values are ruled by environment settings, such as the DBDATE and DBCENTURY enviroment variables. Dates can be formatted with the USING operator. For more details, see Formatting DATE values.
LET date_var = "24/12/1998" -- DBDATE dependant code LET date_var = MDY(12,24,1998) -- Portable code
MAIN DEFINE d DATE LET d = TODAY LET d = d + 10 -- Add 10 days LET d = d - 20 -- Substract 20 days DISPLAY "d = ", d USING "yyyy-mm-dd" END MAIN
MAIN DEFINE d1, d2 DATE LET d1 = MDY(12,24,1998) LET d2 = MDY(5,11,2010) DISPLAY "d2 - d1 = ", (d2-d1) END MAIN
MAIN DEFINE d DATE, dt DATETIME YEAR TO FRACTION(3) LET d = TODAY LET dt = d; DISPLAY "dt = ", dt LET dt = CURRENT LET d = dt; DISPLAY "d = ", d END MAIN
MAIN DEFINE d0, d date LET d0 = MDY(01, 31, 2015) LET d = d0 + 1 UNITS MONTH; DISPLAY d LET d = d0 - 1 UNITS MONTH; DISPLAY d LET d = d0 - 2 UNITS MONTH; DISPLAY d END MAIN