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
Solved

Calculate number of hours using two field

Posted on 2014-04-16
9
323 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
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 13

Expert Comment

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

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 49

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 49

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

840 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