# How to convert the time between to fields into total minutes?

PROBLEM DESCRIPTION
I have an ms access application with two fields the you enter the beginning sampling time and the ending sampling time. THe field that I wanted to have automatically updated this the total sampling minutes is the "total Sampling Time in Minutes Field".
WHAT I HAVE TRIED
I have tried entering placing formulas in both the Start sampling time and the End Sampling time and only get errors.
RECREATE PROBLM
Recreate problem

1.      Open application
2.      The application will open to form: frmlSilicSamplingSetup
3.      Click the Sample Setup button
4.      Enter ID: 1
5.      Scroll down to the bottom of the screen until you reach the green section.
6.      In the green section, look for the following fields:
      Sampling Start Time
      Sampling End time
      Total Sampling Time in Minutes

7.      Notice how the field “Total Sampling Time” does not calculate the total minutes of sample time. This is what I cannot figure how to do?

aNY HELP IS APPRECIATED
Silica_App---V3---Copy---Copy---Co.accdb
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Owner, Developing Solutions LLCCommented:
I cannot download your database at the moment, but if the two fields involved are of date/time data type, then you should use the DateDiff() function.  Format would look something like:

ElapsedTime: DateDiff("n", [StartDateTime], [EndDateTime])

the "n" represents minutes as "m" represents month

Dale
0
Database ExpertCommented:
How you are calculating minutes ? ...Same as Dale Suggested.. you need to use like below

[Total Sampling Time in Minutes] = DATEDIFF("n",[Sampling Start Time],[Sampling End time])

Refer DateDiff for more details - https://www.techonthenet.com/access/functions/date/datediff.php
0
Excel & VBA ExpertCommented:
If the Sample Start Time and Sample End Time have the Date/Time datatype, the above solutions would work for you. Make sure both times have the correct data type.

And in that case you may also try this formula to get Total Sampling Time in Minutes...
``````([Sampling End Time]-[Sampling Start Time])*24*60
``````
0
CIOCommented:
You doesn't need the total field in table. Remove it, and set the ControlSource of the total textbox on the form to:

``````=DateDiff("n",[Sampling Start Time],[Sampling End time])
``````

That said, you really should read up on how to normalize a database. Your table is a monster, and - as is - it will cause you headaches sooner or later.

/gustav
0

Experts Exchange Solution brought to you by