Time Operators

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

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:

OperationSyntaxReturnsExpressionValue
AdditionTime + TimeTime?02:03:04? + ?01:02:03??03:05:07?
SubtractionTime – TimeTime?02:03:04? – ?01:02:03??01:01:01?
AdditionTime + NumberNumber?02:03:04? + 657449
SubtractionTime – NumberNumber?02:03:04? – 657319
MultiplicationTime * NumberNumber?02:03:04? * 214768
DivisionTime / NumberNumber?02:03:04? / 23692
Longint divisionTime \ NumberNumber?02:03:04? \ 23692
ModuloTime % NumberNumber?02:03:04? % 20

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

See Also

Bitwise Operators, Comparison Operators, Date Operators, Logical Operators, Numeric Operators, Operators, Picture Operators, String Operators.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next