Following are brief descriptions of the functions that apply to time values. For more detailed information about a specific function (such as usage and syntax), click the function name.
Function | What it does |
---|---|
Adds a specified number of seconds, minutes, hours, days, months, or years to the current time and returns the new time. |
|
Converts a time to another data type or converts another data type to a time. |
|
Returns the number of days or seconds between two times. |
|
Converts a string expression to a time expression, using a specified mask. |
|
Returns the current time on the system. |
|
Converts a time expression to a string expression, using a specified mask. |
|
Converts a time to a number representing the day of the week (0-6, 0 = Sunday, 6 = Saturday). |
The functions that add time to a given time value are addseconds, addminutes, addhours, adddays, addmonths, and addyears. Use these functions to compute past and future times. Use the following syntax for all of these functions.
addseconds (time_expr, no_of_seconds)
addminutes (time_expr, no_of_minutes)
addhours (time_expr, no_of_hours)
adddays (time_expr, no_of_days)
addmonths (time_expr, no_of_months)
addyears (time_expr, no_of_years)
where: |
time_expr |
is an expression of type time. |
|
no_of_seconds no_of_minutes no_of_hours no_of_days no_of_months no_of_years |
are integer expressions that represent the amount of time to be added to time_exp. If you enter a float value for the amount of time, such as 5.4 or 27.9, only the integer part of the number is used (for example, 5 or 27). |
To compute a past time, subtract time from the time expression by entering a negative number for the integer expression.
Use the expression below to raise a flag of some kind a certain number of hours after the entry time. Entry_time is a variable while num_hours is the number of hours to add to Entry_time.
addhours (Entry_time, num_hours)
The algorithm used to evaluate the addmonths and addyears functions might differ from the way comparable calculations are made in various development environments. For the addmonths function, if adding the specified number of months produces a date beyond the end of the new month, the function returns the first day of the next month. For example, the following expression returns 03/01/1997.
addmonths (convert("01/31/1997 12:00:00", time), 1)
Evaluations of the addyears function are comparable. For example, the following expression returns 03/01/2001.
addyears (convert("02/29/2000 12:00:00", time), 1)
Note that the time format you enter (in this case, the full date and time) must match the date/time mask on the Process Engine. See Time mask components for additional information.
These functions return an integer that represents the number of either days or seconds between two times. Use the following syntax:
days_between (later_time, earlier_time)
seconds_between (later_time, earlier_time)
where later_time and earlier_time are expressions of type time. If you change the order of the earlier time and the later time, the returned integer is negative.
For the days_between function, note that the time is truncated before the date is calculated. For example, the difference between 8/10/1990 23:59:59 and 8/11/1990 0:0:0 is one second, but days_between would return a difference of one day. If your application needs more than plus-or-minus 24 hours accuracy, use the seconds_between function and then convert the returned number of seconds to the time unit you need.
TIP You can determine the number of seconds between two times by simply subtracting the times.
This function returns an integer that represents the day of the week. The integer can range from 0 to 6, with the results varying by Process Engine (PE) platform as follows:
Value | UNIX server | Windows server |
0 | Sunday | Monday |
1 | Monday | Tuesday |
2 | Tuesday | Wednesday |
3 | Wednesday | Thursday |
4 | Thursday | Friday |
5 | Friday | Saturday |
6 | Saturday | Sunday |
Use the following syntax:
weekday (time_expr)
where time_expr is an expression of type time.
The following example takes the systemtime() function as input. If the system time is Tuesday, the weekday function returns the value 1 or 2, depending on the server platform.
weekday (systemtime())
This function returns the server's current time as the number of seconds from midnight of January 1, 1970, Coordinated Universal Time (UTC).
Use the following syntax:
systemtime()
You can store the returned value in a data field; doing so can be a useful way to mark the beginning or ending of a task. Note, however, that functions in data field initial value expressions are evaluated when the workflow definition is transferred, not when a work item is created. Systemtime() is the default initial value for time data fields, and it reflects the time of transfer rather than the time of work item creation.
You can also use the systemtime() function as input for various time functions, such as addhours and weekday.
NOTE How the current time displays to the end user depends on the application the user is looking at. The Process applications display time values based on the locale of the end user client machine.