Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Calculate number of hours using two field

Posted on 2014-04-16
Medium Priority
341 Views
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
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

LVL 35

Expert Comment

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

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

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

LVL 13

Expert Comment

ID: 40005285
Hours.xlsx
0

LVL 52

Accepted Solution

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 52

Expert Comment

ID: 40005318
You are fast!

/gustav
0

LVL 13

Expert Comment

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

LVL 52

Expert Comment

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

/gustav
0

LVL 13

Expert Comment

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

## Featured Post

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
###### Suggested Courses
Course of the Month11 days, 22 hours left to enroll

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

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