Date type

The date type is used to hold a date without any time component.

Declaration
The keyword indicating a string variable is date, although it's generally considered best practice to use a more specific Extended data type (EDT) in all cases.

date someDate = systemDateGet;

Manually
Date variables can be set to a specific date by using the syntax shown in the following example.

There are various commonly-used helper methods to set a date variable.

date d = 29\09\2012; // Set d to the 29th of September 2012

mkDate method
As shown below, a specific date can alternatively be set using the mkDate function. date d = mkDate(29, 9, 2012); // Set d to the 29th of September 2012

systemDateGet method
The systemDateGet method will set the variable to the current system date. This is usually the calendar date, but can be set on a per-session basis by the user.

date d = systemDateGet; // Set d to the system date

today method
The today method always returns the calendar date.

date d = today; // Set d to the current machine date of the client or server computer as appropriate

This method does not have any time zone support. Depending on whether the method is running client- or server-side, the local date on the client or AOS machine respectively will be returned to the caller.

Date mathematics
It is possible to add or subtract one or more days from any date variable by using simple arithmetic plus or minus operators;

d++; // Add one day to d d = d - 2; // Subtract two days from d