Tivoli Service Desk 6.0 Developer's Toolkit Script Language Reference
Return to Main Page
A system-defined function that returns the current time.
FUNCTION $Now: TIME;
VARIABLES t: Time; ACTIONS t:=$Now;
A system-defined function that returns the current date.
FUNCTION $Today: DATE;
VARIABLES d: Date; ACTIONS d:=$Today;
Adds days, months, or years to a date.
FUNCTION DateAdd (VAL d: DATE, VAL n: INTEGER [,$DAYS|$MONTHS|$YEARS] ): DATE;
Argument Name | Description |
d | The date to which n units are to be added. |
n | The number to be added. This must be in one of the defined
units. $DAYS $MONTHS $YEARS |
$DAYS, $MONTHS, $YEARS | The units used to express n. If this argument is omitted, the default is $DAYS. |
This function returns a date which is the n argument number of days, months, or years from the d argument date. If the n argument is positive, the result follows the given date. If the n argument is negative, the result precedes the given date.
Results are adjusted to yield valid dates. When the units parameter is $MONTHS, the result adjusts to allow for 28- and 30- day months.
When the units parameter is $YEARS, the result adjusts to allow for leap years. For example, if you to add one month to a base date of January 31, 1999, the result is March 3, 1999, not February 31, 1999.
dueDate := DateAdd(billingDate, 30);
The result of the calculation is returned.
Calculates the difference between two dates.
FUNCTION DateDif (VAL day1: DATE, VAL day2: DATE [,$DAYS|$MONTHS|$YEARS] ): INTEGER;
Argument Name | Description |
day1 | A date expression. |
day2 | A date expression. |
$DAYS, $MONTHS, or $YEARS | The units used to express the difference between dates. If this argument is omitted, the default is $DAYS. |
DateDif calculates the difference between two dates by subtracting the day2 argument from the day1 argument and returns an integer result in days, months, or years.
Note: If the day2 argument is more recent than the day1 argument, a negative number is returned.
VARIABLES i: INTEGER; ACTIONS i:= DateDif ($Today,{1,1,1998}: DATE,$Days); (* calculates how many days it is since 1/1/1998 *)
DateAdd
Inspects or alters the default text format for date values.
FUNCTION DateFormat [ ( VAL format: INTEGER ) ] : INTEGER;
Argument Name | Description |
format | If provided, this argument replaces the default format |
This function is used to inspect and alter the default format when a date value is converted into a text form. If called with no argument, DateFormat returns the current default date format.
If an argument is provided, that value becomes the new default date format. DateFormat returns the old default date format.
Note: For a list of display format constants, see "DataType Format Flags."
CONSTANTS oracleDate IS $FmtDateYearMonthDay + $FmtDateTruncateCentury + $FmtDateDashSeparators + $FmtDateNamedMonth + $FmtDateShortNames + $FmtDateAllCaps + $FmtZeroPad; VARIABLES oldFormat: INTEGER; ACTIONS oldFormat := DateFormat (oracleFormat); ... DateFormat (oldFormat); END;
Adds seconds, minutes, or hours to a time in the units you specify.
FUNCTION TimeAdd (VAL t: TIME, VAL n: INTEGER [, $SECONDS|$MINUTES|$HOURS] ): TIME;
Argument Name | Description |
t | The original time. |
n | Amount of time to add. The choices are:
The default units in which the sum of t+n is returned is $SECONDS. |
TimeAdd
returns the new time in the units you specified.Returns the difference between two times in hours, minutes, or seconds.
FUNCTION TimeDif (VAL t1, t2: TIME [,$SECONDS|$MINUTES|$HOURS] ):INTEGER;
Argument Name | Description |
t1 | A time expression. |
t2 | A time expression. The choices are:
The default for units in which the difference is to be returned is $SECONDS. |
TimeDif calculates the difference between two time expressions and returns the difference. The second argument is subtracted from the first (time_1-time_2) and is expressed in hours, minutes, or seconds depending upon the system constant passed as the third argument.
When the third argument is $MINUTES or $HOURS, the result is truncated. Thus, the difference between {7,0,0}:TIME and {8,59,59}:TIME is 7199 seconds, or 119 minutes, or 1 hour.
VARIABLES i: INTEGER; ACTIONS i:=TimeDif($Now,{8,30,0}: TIME,$Minutes); (* i = number of minutes since 8:30 this morning *) i:=TimeDif ($Now, TimeAdd({8,30,0}:TIME, 30, $MINUTES), $HOURS); (* i=number of hours since 8:30 this morning, rounded to *) (* the nearest hour *)
Return Code | Description |
any | Time difference. |
Inspects or alters the default text format for time values.
FUNCTION TimeFormat [ ( VAL format: INTEGER ) ] : INTEGER;
Argument Name | Description |
format | If provided, this argument replaces the default. |
TimeFormat inspects or alters the default format whenever a value of this type is converted into a text form.
If called with no argument, TimeFormat returns the existing default. If an argument is provided, that value becomes the new default. (The old default is returned.)
VARIABLES oldFormat: INTEGER; ACTIONS oldFormat := TimeFormat(BitOr($FmtTimeAMPM, $FmtTimeWithoutSeconds)); ... TimeFormat(oldFormat); END;
For an explanation of display formats, see Data Type Format Flags.
Tivoli Service Desk 6.0 Developer's Toolkit Script Language Reference