* Rick C. Hodgin born at approximately 4:35am, 08/10/1969 ldStart = CTOD("08/10/1969") lnStart = (4*60*60) + (35*60) * How old is Rick C. Hodgin now? ? "Rick C. Hodgin is approximately this old:" ? timeBetween(ldStart, lnStart, DATE(), SECONDS()) ********** * Note: You can also directly obtain the individual elements using: *STORE 0 TO lnYears, lnDays, lnHour, lnMinute, lnSecond, lnMillisecond *? timeBetween(ldStart, lnStart, ldEnd, lnEnd, .F., @lnYears, @lnDays, @lnHour, @lnMinute, @lnSecond, @lnMillisecond) *? lnYears, lnDays, lnHour, lnMinute, lnSecond, lnMillisecond ********** ********** * pdStart = DATE() at start * pnStart = SECONDS() at start * pdEnd = DATE() at end * pnEnd = SECONDS() at end * plIncludeAll = Include all fields in output? ***** FUNCTION timeBetween LPARAMETERS pdStart, pnStart, pdEnd, pnEnd, plIncludeAll, lnYears, lnDays, lnHour, lnMinute, lnSecond, lnMillisecond LOCAL lnSeconds * Compute the total number of seconds lnSeconds = ((pdEnd - pdStart) * (24 * 60 * 60)) + (pnEnd - pnStart) * Now, you can obtain the minutes by each lnYears = INT(lnSeconds / (365.25 * 24 * 60 * 60)) lnSeconds = lnSeconds % (365.25 * 24 * 60 * 60) lnDays = INT(lnSeconds / (24 * 60 * 60)) lnSeconds = lnSeconds % (24 * 60 * 60) lnHour = INT(lnSeconds / (60 * 60)) lnSeconds = lnSeconds % (60 * 60) llAm = (lnHour <= 12) lnMinute = INT(lnSeconds / 60) lnSeconds = lnSeconds % 60 lnSecond = INT(lnSeconds) lnMillisecond = INT((lnSeconds % 1) * 1000) RETURN IIF(plIncludeAll OR lnYears != 0, TRANSFORM(lnYears) + " years ", SPACE(0)) + ; IIF(plIncludeAll OR lnDays != 0, TRANSFORM(lnDays) + " days ", SPACE(0)) + ; IIF(plIncludeAll OR lnHour != 0, TRANSFORM(lnHour) + " hours ", SPACE(0)) + ; IIF(plIncludeAll OR lnMinute != 0, TRANSFORM(lnMinute) + " minutes ", SPACE(0)) + ; IIF(plIncludeAll OR lnSecond != 0, TRANSFORM(lnSecond) + " seconds ", SPACE(0)) + ; ALLTRIM(STR(lnMillisecond,3,0)) + " milliseconds"