KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Comparing Time values in Long Integer “Time” Arrays
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: October 29, 1999
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

4D does not have a time array. Instead it stores time values in a Long Integer array. If you need to compare a time value stored in a Long Integer array with a time, you need to convert the time value to a Long Integer first then compare the values. The most efficient way of converting a time is to use the time addition operator. Such as:

vTime:='02:00:00'+0

The addition operator converts the time 2:00 to 7200. 0 (zero) is used because a value needs to be added but it is not desirable to modify the outcome of the addition operator. (Note: 7200 is the number of seconds that occurred from start of the day to 2:00 AM.) The fallowing code displays several examples of using the time addition operator to convert time values to Long Integer.

ARRAY LONGINT(aTime;3)
aTime{1}:=†01:00:00†+0 ` assign the longint of XX:00 to a longint array
aTime{2}:=†02:00:00†+0
aTime{3}:=†03:00:00†+0

C_TIME(vTime)
vTime:=†02:00:00†

C_LONGINT(vLongint)
vLongint:=vTime+0 ` assign the longint for vTime to vLongint

ALERT(String(Find in array(aTime;vLongint))) ` find vLongint in the array, returns 2

ALERT(String(Find in array(aTime;vTime+0))) ` find the longing of vTime in the array, also returns 2

For more information on working with time value consult the “Time Operators” section of the “Operators” chapter of the Language Reference Manual.