Datetime Expressions
Datetime expressions consist of a datetime variable and (optionally) datetime modifiers.
Datetime expressions can be written using datetime constants if you are using the standard syntax, as follows:
year/month/day
hour:minute:second
year/month/day/hour:minute:secondDatetime expressions can also be written with datetime fields, variables, or using date and time functions.
Syntax
Date functions are written as follows (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 format
type into a datetime format type by indicating a format mask ("%y/%m/%d")
along with the string ("01/4/6") you want to convert. You use this
function if you are using non-standard syntax and need to specify
the syntax you are using.
<< operator
You can use the << operator to modify your datetime variable by adding time increments (for example, days, weeks, years). For example:
datetime d;
d=d <<weeks(2);
//This adds 2 weeks to d.Time syntax
Time functions are written as follows:
d = time(12,0);
d = time(12,0,59);You can use the << operator to modify your datetime variable by adding time increments (for example, seconds, minutes, years). For example:
datetime d;
d=d <<seconds(1);
//This adds 1 second to d.Get and set syntax
The get and set functions enable you to access (get) or modify (set) individual components of a datetime type. These functions are used as follows:
integer a;
datetime d;
a = get days (d);
a = get hours (d);
set hours(d,a);
set days (d,a);