DATE

 

Calendar dates are stored using the DATE data type. The value of DATE type is stored as an integer that represents the number of days that have passed since December 31, 1899. If a DATE value represents a date before December 31, 1899, the stored integer is negative. The default display format of a DATE value depends on the settings of the system on which it is used. If the U.S. English settings are used as default for the system, the default format of a DATE value is:

 

mm/dd/yyyy

 

where mm stands for a month (acceptable values are 1 to 12), dd stands for a day (acceptable values are 1 to 31) and yyyy stands for a year (acceptable values are 0001 to 9999).

 

LET my_birthday = "11/28/1978"

 

The default format can be changed with the help of DBDATE environment variable which can change the delimiter symbol or the order of units.

 

GL_DATE environment variable can specify a wider range of formats than the DBDATE variable can. E.g. In some East Asian locales it can make DATE data type accept and display Taiwanese or Japanese eras.

 

If a user enters one or two symbols for the value of a year (5 or 05), 4GL uses the settings of the DBCENTURY environment variable to restore the first two or three digits of the year. If you want to specify a year outside the current century, you must specify all the four digits, e.g. 1805.

 

If you want to specify a year of the first century Anno Domini (which is also known as Common Era - CE), you should enter leading zeros, e.g. 053 or 0053 for the year 53 A.D. It is not possible to use DATE data type to specify years BC.

 

 

The settings of the DBCENTURY variable do not affect dates stored in CHAR, STRING and VARCHAR data types. To override the settings of this variable for the DATE data type, the individual field attribute CENTURY may be used for the form fields of DATE type.

 

You can perform arithmetic operations using variables of DATE type, because they are stored as integers. E.g. you can use two values of DATE data type in an arithmetical expression to find the difference between them. You will get a positive or negative value of the INTEGER data type that will represent the number of days that have passed between the two dates. This integer value can be converted to INTERVAL data type with the help of UNITS DAY operator. However, you will not get meaningful values if you try to divide or multiply values of DATE type.

 

You can change the default display of the DATE data type in screen forms using FORMAT attribute. The DATE data type can accept the following formats for months: 01, 1, January. It can accept 1 or 01 for the day format.