Greetings to all...Need help with calculation!

  • Thread starter Thread starter Lupus
  • Start date Start date
L

Lupus

Guest
I have created a rather complex database (this is my first one, I'm still a newbie) and have the need to calculate total time, in hours and minutes, from 4 fields (on a form); FromDate, FromTime, EndDate, EndTime. Right now, we have a field for Hours where you manually enter the total time for that period. I need this calculation to calculate only the total hours per activity, i.e. 10/26/01 22:15 to 10/27/01 01:30 should fill in a form field with the total of 3.25. Any help will be GREATLY appreciated.

Thank you in advance.
 
The following formula calculates the number of minutes based on the fields you have available:

=IIf(IsNull([FromDate]),0,IIf(IsNull([EndDate]),0,(DateDiff("n",Format([FromDate] & " " & [FromTime],"dd/mm/yyyy hh:nn:ss"),Format([EndDate] & " " & [EndTime],"dd/mm/yyyy hh:nn:ss")))/60))

It also has a couple of checks upfront to see if the dates have been entered. If you only want to track whole hours, change the DateDiff value of "n" to "h" and remove the /60 from the calculation.

HTH
SteveA

Updated field names to reflect yours
smile.gif


[This message has been edited by SteveA (edited 10-26-2001).]
 

Users who are viewing this thread

Back
Top Bottom