You should read the help on Clarion Standard Date so you understand a Date in a LONG is stored as the number of Days since 12/28/1800. To get Days between dates you can simply subtract the 2 dates. It harder to use human understandable forms for Day, Month, Year. For that use FORMAT(, @d#) or functions Day(), Month(), Year(), Date().
Also read about Clarion Standard Time so you understand a Time in a LONG is stored as the number of Hundredths of Seconds since midnight … Plus 1 … that +1 is important.
TimeHMS PROCEDURE(SHORT H, SHORT M, SHORT S=0, SHORT Hundredths=0)!,LONG
!This allows out of range HMS values, e.g. you can pass 90 minutes. This can produce an invalid time beyond 23:59:59.
CODE
RETURN (H * 60*60*100) + |
(M * 60*100) + |
(S * 100) + |
Hundredths + 1
The DATE and TIME types are different with the Internal Format as YYYYMMDD and HHMMSShh. Anytime they are used in code they are converted to Standard versions i.e. YMD becomes Days since 12/28/1800.
These can be used in code like below to split a DATE or TIME into parts. For dates you have functions for this. Time does not have these so this type of function can be used, or FORMAT(,@T05) that’s HHMMSS.
DateSplit PROCEDURE(LONG Date2Split, *? OutMonth, *? OutDay, *? OutYear)
!==============================================================================
DateSplit PROCEDURE(LONG D, *? OutMonth, *? OutDay, *? OutYear)
!This is much faster than calling MONTH() DAY() YEAR()
D1 DATE
DG GROUP, OVER(D1)
D BYTE
M BYTE
Y USHORT
END
CODE
D1=D
OutMonth=DG.M
OutDay=DG.D
OutYear=DG.Y
RETURN
!--------------------------------------------------------------------
TimeSplit PROCEDURE(LONG T, *? OutHour, *? OutMin, <*? OutSec>, <*? OutHund>)
!This is faster than using HOUR() MINUTE() SECOND()
T1 TIME
TG GROUP, OVER(T1)
F BYTE
S BYTE
M BYTE
H BYTE
END
CODE
T1=T
OutHour=TG.H
OutMin =TG.M
IF ~OMITTED(OutSec) THEN OutSec =TG.S.
IF ~OMITTED(OutHund) THEN OutHund=TG.F.
RETURN