Solved

Calculate number of hours using two field

Posted on 2014-04-16
9
328 Views
Last Modified: 2014-04-16
I have a form which has two fields.  They are "StartTime" and "StopTime".

In the bound table I have a calculated field named "ElapsedTime".  I want to have that field populate with [StopTime] - [StartTime] in hours.

If StartTime for example is "4/16/2014 2:53:50 PM"
and
If StopTime for example is "4/16/2014 3:01:05 PM"

then the elapsed hours would be something like .13 right?  

Anyway, how can I make the calculated field get the right result?  I have it setup as Long Integer, Standard, 2 decimals but it isn't working correctly.

--Steve
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 35

Expert Comment

by:Bembi
ID: 40005079
Long integer values do not have decimals. And as time value are measured in days, an integer can not calculate hours. Hours are calculated as parts of a day, let say 6am is 0,25 and 6pm is 0,75. THe difference is 0,5 means half a day = 12h.
If you use single or double as field type, it should work.
0
 
LVL 13

Expert Comment

by:akb
ID: 40005237
Set the field as General or as a Number if you want to fix decimal points.
Multiply the answer by 24 to get hours.
Or multiply the answer by 1440 to get minutes. 1440 = 24 * 60.
0
 

Author Comment

by:SteveL13
ID: 40005265
This isn't quite getting it.  Again:

If StartTime for example is "4/16/2014 2:53:50 PM"
and
If StopTime for example is "4/16/2014 3:01:05 PM"

then the elapsed hours would be something like .13 right?

How do I get the calculated field to read .13 ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:akb
ID: 40005285
See attached spreadsheet
Hours.xlsx
0
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40005313
For ElapsedTime you can use this expression as ControlSource:

=([StopTime]-[StartTime])*24

and apply this for the Format property:

0.00

/gustav
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40005318
You are fast!

/gustav
0
 
LVL 13

Expert Comment

by:akb
ID: 40005331
Isn't that exactly what I gave you in the spreadsheet??
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40005344
Well, this is Access, and rounding was missing.

/gustav
0
 
LVL 13

Expert Comment

by:akb
ID: 40005367
Sorry. Don't know where I got Excel from!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question