Date Syntax
Date functions have the following syntax (month specified as 1 - 12):
datetime d;
d = date(1995,4,6);
d = date(1995,4,6,12,0);
d = date("%y/%m/%d", "95/4/6");
The d = date("%y/%m/%d", "95/4/6"); format enables you to convert any string type into a datetime type by indicating a format mask ("%y/%m/%d") along with the string ("95/4/6") you want to convert. Use this function if you are using nonstandard syntax and must specify the syntax you are using.
For more information about date syntax, see date.
For example, if you want to add five days to a date in a field, you must:
- Verify that you are using a standard rule that loads the current date into a field.
For more information about loading a date into a field, see Using the System Variable Standard Rule.
- Use the following extended rule logic to add five days to the date in that field:
#TheField = #TheField << days(5); //The field is called #TheField
<< Operator
You can use the << operator to modify your datetime variable by adding time increments. Valid modifiers are:
- years
- months
- weeks
- days
- hours
- minutes
- seconds
For example:
datetime d;
d=#Date_Field <<weeks(2);
//This adds 2 weeks to the date in the date field named Date_Field
Time Syntax
Time functions have the following syntax:
d = time(12,0);
d = time(12,0,59);
You can use the << operator to modify your datetime variable by adding time increments (seconds, minutes, years). For example:
datetime d;
d=#Time_Field <<seconds(1);
//This adds 1 second to the time field named Time_Field
get and set Syntax
The get and set functions enable you to access (get) or modify (set) individual components of a datetime type. For more information about the get and set functions, see get and set.
Here is the syntax to use:
integer a;
datetime d;
a = get days (d);
a = get hours (d);
set hours(d,a);
set days (d,a);