Can you do calcuations with time fields in forms? 
Author Message
 Can you do calcuations with time fields in forms?

To anyone who is willing to help:

Is it possible to do calculations with time fields in forms or reports so
that the difference in hours is displayed as a number (4:00 PM - 7:45 AM =
8.25 hours)?  I have not had much luck with this.  I am new to paradox and
cannot find any help from the owner's manual or a third party manual.

I can do math with time fields but the numbers appear as fractional numbers
less than one.  Can anyone help me?

Thanks
Dan



Tue, 26 Oct 1999 03:00:00 GMT
 Can you do calcuations with time fields in forms?

It should be simpler but its not.  You have to calculate the hours and
minutes separately.  Here is a calculation between two time fields that
works correctly whichever time is later.  If there is no possibility
that the times can be interchanged, you can skip the iif() and just use
the second argument in the iif().  Hope this helps.

iif([ECTRFLOW.Arrived]>[ECTRFLOW.Appointment],(hour([ECTRFLOW.Arrived]-[
 C
TRFLOW.Appointment]))*60+minute([ECTRFLOW.Arrived]-[ECTRFLOW.Appointment
 )
,-((hour([ECTRFLOW.Appointment]-[ECTRFLOW.Arrived]))*60+minute([ECTRFLOW
 A ppointment]-[ECTRFLOW.Arrived])))



Fri, 29 Oct 1999 03:00:00 GMT
 Can you do calcuations with time fields in forms?

Quote:

> To anyone who is willing to help:

> Is it possible to do calculations with time fields in forms or reports so
> that the difference in hours is displayed as a number (4:00 PM - 7:45 AM =
> 8.25 hours)?  I have not had much luck with this.  I am new to paradox and
> cannot find any help from the owner's manual or a third party manual.

> I can do math with time fields but the numbers appear as fractional numbers
> less than one.  Can anyone help me?

> Thanks
> Dan

After reading and testin the code from Joern, and finding that it didnt
work I sat down and came up with the method below.  If the code is
installed as a new method on the form level then to calculate elapsed
time is very easy.

Just

t=elapsedTime("08:00","17:15")

Ok I know it looks complicated and probably is but it works!

HTH

Che

method elapsedTime(start String,end String) string
var
  st,et                 String
  h,m,oh,
  tsm,tem,
  sh,eh,
  sm,em                 SmallInt
endvar

  st=Start
  et=End

  sh=smallInt(st.substr(1,st.search(":")-1))
  sm=smallInt(st.substr(st.search(":")+1,2))
  tsm=sm+(sh*60)

  eh=smallInt(et.substr(1,st.search(":")-1))
  em=smallInt(et.substr(st.search(":")+1,2))
  tem=em+(eh*60)
  tt=tem-tsm

  h=smallInt(tt/60)
  if h<0 then
    oh=h
    h=(h*-1)
    h=(24-h)
    tt=tt-(oh*60)
  else
    tt=tt-(h*60)
  endif
  m=tt
  if m<0 then
    h=h-1
    m=60+m
  endif
  return string(h)+"h"+string(m)+"m"
endmethod



Sat, 30 Oct 1999 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. time field on form

2. Access does not seem to do calcuations on dates properly

3. making a mdi form a form during run time with click event

4. MDX : Canned Report or OLAP

5. Doing Time Zone Offsets

6. Anyone know of some canned (cheap or free) DB performance testing software

7. canned code to get db on web quickly via perl or

8. Doing math with time...

9. Cans access2.0 engine access btrieve files?

10. ADO with Access Date/Time field not storing the time, just the date

11. Can't read time from Access 2000 date/time field

12. Just done my first app in Forms!


 
Powered by phpBB® Forum Software