Axaptapedia is now maintained by AgileCadence For more information please click here.
Date type
The date type is used to hold a date without any time component.
Contents
Declaration[edit]
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.
<xpp> date someDate = systemDateGet(); </xpp>
Setting dates[edit]
Manually[edit]
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.
<xpp> date d = 29\09\2012; // Set d to the 29th of September 2012 </xpp>
mkDate method[edit]
As shown below, a specific date can alternatively be set using the mkDate function. <xpp> date d = mkDate(29, 9, 2012); // Set d to the 29th of September 2012 </xpp>
systemDateGet method[edit]
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.
<xpp> date d = systemDateGet(); // Set d to the system date </xpp>
today method[edit]
The today() method always returns the calendar date.
<xpp> date d = today(); // Set d to the current machine date of the client or server computer as appropriate </xpp>
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[edit]
It is possible to add or subtract one or more days from any date variable by using simple arithmetic plus or minus operators;
<xpp> d++; // Add one day to d d = d - 2; // Subtract two days from d </xpp>