473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Calculating\Displaying Time over 24 hrs


I have a 2000/2002 Access db that I use to collect and store my exercisetime using a form to enter. I wanted to see a summary of the total timefor each exercise so I have a subform that does this. Only issue is thatwhen I go over 24 hrs I get the infamous summing time issue. It would bereally easy if Access used the Excel [h]:nn format, but it doesn't. Whycan't this be used in Access, Microsoft?????????????????..anyway Idigress.

I have two text boxes, one for the detail called txtTime and one for theSummary called txtTotalTime. txtTime control source would normally be thedata field Time and txtTotalTime is just =Sum([Time]).

However, since it does not add up correctly, I added this code as a PublicFunction.

===========================================
Public Function TotalTimeDisp(lngTotTime As Long) As String

Dim intHours As Integer Dim intMinutes As Integer

intHours = Int(lngTotTime / 60) intMinutes = lngTotTime Mod (intHours * 60)

TotalTimeDisp = Str(intHours) & ":" & Trim(Format(intMinutes, "00"))

End Function ===============================================

and use =TotalTimeDisp(Datepart("n",[total time])) as the control sourcefor the text box txtTime. My issue is that I am getting a #Div/0! error inthe text box.

I would so like to have an easy resolution for this, but I guess my firstquestion is, what format do I need to store the time in. They are inDate\Time right now. Do I need to change this to text or a number? Anyhelp would be appreciated.

Thanks, Brian



Mar 21 '08 #1
4 2405
Brian wrote:
So with this should I input as =[time]\60 & ":" & [time] MOD 60 in my
control source?
When I put this in as my control source, it displays 7:28 as 0:9.
You would not use Larry's suggestion on a DateTime field. You should
instead be using a numeric field to store the number of minutes. THEN
Larry's suggestion would allow you to display that value in an hours:minutes
format.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Mar 21 '08 #2
Actually, to display

= timemin\60 & ":" & timemin MOD 60

you wouldn't want it defined as numerical; the colon between hours and
minutes would pop an error, I believe.

The point about elapsed time not being held in a Date/Time field is an
important one, though! People often get time and elapsed time confused.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200803/1

Mar 21 '08 #3
Linq Adams via AccessMonster.com wrote:
Actually, to display

= timemin\60 & ":" & timemin MOD 60

you wouldn't want it defined as numerical; the colon between hours and
minutes would pop an error, I believe.
The resut of the expression would not be numerical. The field named timemin
however would be as we are performing arithmetic operations with it.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Mar 21 '08 #4
Brian <no*****@bellsouth.netwrote in
news:200832111830.171583@Brian-PC:
>
I have a 2000/2002 Access db that I use to collect and store my
exercise time using a form to enter. I wanted to see a summary of
the total time for each exercise so I have a subform that does
this. Only issue is that when I go over 24 hrs I get the infamous
summing time issue. It would be really easy if Access used the
Excel [h]:nn format, but it doesn't. Why can't this be used in
Access, Microsoft?????????????????..anyway I digress.
Excel isn't a database, Excel is wrong.

The problem begins when people confuse a duration, (which may be
expressed in hours:minutes) with a time which is a specific event
and also may be expressed in hours:minutes.

So you have a time when your excercise started, a second time when
your excercise finished, and a duration from the start and finish
times.

If you store the start and finish times, the duration can be
calculated as datediff("n",start,finish). You could instead store
the duration as the number of minutes. That number is the duration
you want. You can then use a custom format in a function to show it
as hh:mm or ddd:hh:mm as you wish, something like duration\60 & ":"
& duration mod 60

You could also write a custom function to parse user input of hh:nn
into minutes for storage.

I have two text boxes, one for the detail called txtTime and one
for the Summary called txtTotalTime. txtTime control source would
normally be the data field Time and txtTotalTime is just
=Sum([Time]).

However, since it does not add up correctly, I added this code as
a Public Function.

==========================================Public Function
TotalTimeDisp(lngTotTime As Long) As String

Dim intHours As Integer Dim intMinutes As Integer

intHours = Int(lngTotTime / 60) intMinutes = lngTotTime Mod
(intHours * 60)

TotalTimeDisp = Str(intHours) & ":" & Trim(Format(intMinutes,
"00"))

End Function ==============================================
and use =TotalTimeDisp(Datepart("n",[total time])) as the control
source for the text box txtTime. My issue is that I am getting a
#Div/0! error in the text box.

I would so like to have an easy resolution for this, but I guess
my first question is, what format do I need to store the time in.
They are in Date\Time right now. Do I need to change this to text
or a number? Any help would be appreciated.

Thanks, Brian






--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Mar 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bart Nessux | last post by:
am I doing this wrong: print (time.time() / 60) / 60 #time.time has been running for many hours if time.time() was (21600/60) then that would equal 360/60 which would be 6, but I'm not getting...
5
by: David Stockwell | last post by:
I'm sure this has been asked before, but I wasn't able to find it. First off I know u can't change a tuple but if I wanted to increment a time tuple by one day what is the standard method to do...
6
by: David Graham | last post by:
Hi I have asked this question in alt.php as the time() function as used in setcookie belongs to php - or does it belong equally in the javascript camp - bit confused about that. Anyway, can anyone...
4
by: Andrew Poulos | last post by:
How do I convert a length of time, measured in seconds, into a "point in time" type time interval or what's represented as: time (second,10,2) The format is: PS]] where: y: The number of...
8
by: peterbe | last post by:
What's the difference between time.clock() and time.time() (and please don't say clock() is the CPU clock and time() is the actual time because that doesn't help me at all :) I'm trying to...
3
by: Szabolcs Nagy | last post by:
I have to measure the time of a while loop, but with time.clock i always get 0.0s, although python manual sais: "this is the function to use for benchmarking Python or timing algorithms" So i...
6
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to...
5
by: Erich Schreiber | last post by:
In the Python Library Reference the explanation of the time.sleep() function reads amongst others: > The actual suspension time may be less than that requested because > any caught signal will...
5
by: RICHARD BROMBERG | last post by:
I am writing an ASP program that includes a Form. When the Form is submitted I use the Date() and Time() functions to put the date and time into the Body part of the e-mail. The time reported is...
6
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.