## Time Operators

version 6.0

An expression that uses a time operator returns a time or a number, depending on the operation. The following table shows the time operators:

 Operation Syntax Returns Expression Value Addition Time + Time Time ?02:03:04? + ?01:02:03? ?03:05:07? Subtraction Time – Time Time ?02:03:04? – ?01:02:03? ?01:01:01? Addition Time + Number Number ?02:03:04? + 65 7449 Subtraction Time – Number Number ?02:03:04? – 65 7319 Multiplication Time * Number Number ?02:03:04? * 2 14768 Division Time / Number Number ?02:03:04? / 2 3692 Longint division Time \ Number Number ?02:03:04? \ 2 3692 Modulo Time % Number Number ?02:03:04? % 2 0

Tips

(1) To obtain a time expression from an expression that combines a time expression with a number, use the commands Time and Time string.

Example:

```      ` The following line assigns to \$vlSeconds the number of seconds that will be elapsed
` between midnight and one hour from now
\$vlSeconds:=Current Time+3600

` The following line assigns to \$vHSoon the time it will be in one hour
\$vhSoon:=Time(Time string(Current time+3600))

```

The second line could be written in a simpler way:

```      ` The following line assigns to \$vHSoon the time it will be in one hour
\$vhSoon:=Current time+?01:00:00?

```

However, while developing your application, you may encounter situations where a delay, expressed in seconds and added to a time value, is only available to you as a numeric value.

In this case, use the next tip.

(2) Some situations may require you to convert a time expression into a numeric expression.

For example, you open a document using Open document, which returns a Document Reference (DocRef) that is formally a time expression. Later, you want to pass that DocRef to a 4D Extension routine that expects a numeric value as document reference. In such a case, use the addition with 0 (zero) to get a numeric value from the time value, but without changing its value.

Example:

```      ` Select and open a document
\$vhDocRef:=Open document("")
If (OK=1)
` Pass the DocRef time expression as a numeric expresssion to a 4D Extension routine
DO SOMETHING SPECIAL (0+\$vhDocRef)
End if
```