VFP supports arithmetic on datetime values. When you substract one datetime from another you get the elapsed time in SECONDS.
ie:
datetime(2008,1,1,15,0,0) – datetime(2008,1,1,14,0,0) is 3600 SECONDS.
However be carefull with datetime arithmetic and round the value to 0:
lnSeconds = round(m.ltEnd – m.ltStart, 0)
And here is a little trick for formatting the result as time (in 24hr range):
? TRANSFORM(RIGHT(TTOC(CTOT(‘0′)+(m.ltEnd – m.ltStart),1),6),’@R 99:99:99’)
if you are using datetime fields then u can simply use
higherDateTime – lowerDateTime
it will give u result in milliseconds
if you are using time fields then you have to extract hours, minutes (second is u r using)
from both the times and then find out the difference
you can extract any part by using substr or left and right functions
(assuming seconds are off otherwise you need to modify following statements)
lcTime=TIME()
lnHour = val(LEFT(lcTime,2))
lnMinute = val(right(lcTime,2))