?
Solved

Calculate number of hours using two field

Posted on 2014-04-16
9
Medium Priority
?
336 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 13

Expert Comment

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

Accepted Solution

by:
Gustav Brock earned 2000 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 51

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 51

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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

770 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