473,397 Members | 1,960 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,397 software developers and data experts.

Help!! Time Calculations.

Hi all,
I'm creating a TimeSheet Database, I need to calculate how many hours
the Employee works.The problem is that when they enter the time, it
doesn't calculate the minutes, it just calculate hours.it rounds up to
6 and not 5:30.
I'm using this formula:

Me.Hours = (DateDiff("h", Me.Start, Me.Stop))

Ex:
Start Stop Hours
08:30AM 02:00PM 6 <it should be 5 hours and half
I would be grateful, if someone can help me.

Thanks in advanced.
Nov 12 '05 #1
11 6246
cs********@partners.org (christian) wrote in
news:e1**************************@posting.google.c om:
Me.Hours = (DateDiff("h", Me.Start, Me.Stop))

Ex:
Start Stop Hours
08:30AM 02:00PM 6 <it should be 5 hours and half


DateDiff returns, as an integer, the number of interval (in this case the
interval is hours) boundaries crossed. Perhaps you could specify minutes and
divide by 60.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2
Try using the minutes ("n") argument instead and then divide the result by
60 to get hours as a decimal.

Mike Storr
www.veraccess.com
"christian" <cs********@partners.org> wrote in message
news:e1**************************@posting.google.c om...
Hi all,
I'm creating a TimeSheet Database, I need to calculate how many hours
the Employee works.The problem is that when they enter the time, it
doesn't calculate the minutes, it just calculate hours.it rounds up to
6 and not 5:30.
I'm using this formula:

Me.Hours = (DateDiff("h", Me.Start, Me.Stop))

Ex:
Start Stop Hours
08:30AM 02:00PM 6 <it should be 5 hours and half
I would be grateful, if someone can help me.

Thanks in advanced.

Nov 12 '05 #3

Thank you very much.

Could you help me with the formula, because I don't really know where to
divide by 60.
Thanks once again
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4
Thank you very much. Can you show me How to do that?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
Me.Hours = DateDiff("n", Me.Start, Me.Stop) / 60

This will change the DateDiff to calculating minutes and divide that result
by 60. The result will be a decimal representation of the elapsed time (i.e.
5.5 not 5:30). If you want the latter format:

intIntervalMinutes= DateDiff("n", Me.Start, Me.Stop)
Me.Hours = intIntervalMinutes \ 60 & Format(intIntervalMinutes Mod 60,
"\:00")

The backslashes are intentional. The first one is "integer division" and the
second one tells the format command to treat the : as a displayed character
and not part of the format mask.

--
Wayne Morgan
Microsoft Access MVP
"cristian sepulveda" <cs********@partners.org> wrote in message
news:40***********************@news.frii.net...

Thank you very much.

Could you help me with the formula, because I don't really know where to
divide by 60.
Thanks once again
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #6
Thank you very much for the formula.
But when I run the formula, I get this message.
What do you think it could be:

Run-time error '-2147352567 (80020009)':
the value you entered isn't valid for this field.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #7
What data type is the field? Is there an input mask?

--
Wayne Morgan
Microsoft Access MVP
"cristian sepulveda" <cs********@partners.org> wrote in message
news:40***********************@news.frii.net...
Thank you very much for the formula.
But when I run the formula, I get this message.
What do you think it could be:

Run-time error '-2147352567 (80020009)':
the value you entered isn't valid for this field.

Nov 12 '05 #8
cs********@partners.org (christian) wrote in message news:<e1**************************@posting.google. com>...
Hi all,
I'm creating a TimeSheet Database, I need to calculate how many hours
the Employee works.The problem is that when they enter the time, it
doesn't calculate the minutes, it just calculate hours.it rounds up to
6 and not 5:30.
I'm using this formula:

Me.Hours = (DateDiff("h", Me.Start, Me.Stop))

Ex:
Start Stop Hours
08:30AM 02:00PM 6 <it should be 5 hours and half


If you get any closer, the answer will bite you. Get the difference
in minutes and then divide by 60. Then you'll get some number, like
5.333..., which you can round to some number of places.

Me.Hours =Round((DateDiff("n",Me.Start, Me.Stop))/60,2)
Nov 12 '05 #9

yes, the data type is (Number) and it has an input mask of (Short time.)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #10
christian wrote:
Hi all,
I'm creating a TimeSheet Database, I need to calculate how many hours
the Employee works.The problem is that when they enter the time, it
doesn't calculate the minutes, it just calculate hours.it rounds up to
6 and not 5:30.
I'm using this formula:

Me.Hours = (DateDiff("h", Me.Start, Me.Stop))

Ex:
Start Stop Hours
08:30AM 02:00PM 6 <it should be 5 hours and half

I would be grateful, if someone can help me.

Thanks in advanced.


If you are assured the times won't exceed 23 hours and 59 minutes you can
use the timeserial() function
? Format(timeserial(0,90,0),"hh:mm")
this will echo 01:30 The 90 is the number of minutes. If it exceeds the
largest part of time, it does the calcs for you. 90 minutes exceeds 59
minutes to it calcs the hour and minutes.

If you are using numbers, you can subtract. If using times, use
datediff() and calc on minutes.

Please read on-line help for examples on all of the functions I, and
others, have provided you.
Nov 12 '05 #11
Ok, this is probably where the problem is. What type of Number (Long
Integer, Integer, Double)? This will be at the bottom of the table design
window when you have the field selected. What you have here is an elapsed
time, not an actual time. You can store the value as a number (i.e. 5.5) or
as text (i.e. 5:30). You could set it up as a date/time field as long as you
don't go beyond 23:59, if you do it will revert back to 0.

--
Wayne Morgan
Microsoft Access MVP
"cristian sepulveda" <cs********@partners.org> wrote in message
news:40***********************@news.frii.net...

yes, the data type is (Number) and it has an input mask of (Short time.)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #12

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

Similar topics

2
by: Joe User | last post by:
I am looking to calculate the difference between and event time and a sample time of Now. This is the query that I thought would do it, however I'm returning DIFFERENCE values that look the same...
5
by: iminal | last post by:
I am trying to make a very simple program and am very new to the whole programming thing. my program is supposed to ask a user for any time in the for format XX:XX:XX and then ask for a time...
1
by: Heather | last post by:
I have three fields each containing a time unit ie direct, indirect and misc. I am trying to calculate a total (sum) of all. If the data type is 'double' number, how do I convert the total so it...
1
by: Arargorn | last post by:
I am trying to create a database that involves time calculation (elapsed time). I have set up several tables and one is for "Time Card" entry. I cannot figure out how to calculate the elapsed time...
1
by: bluerocket | last post by:
I have searched this group, and am not finding the answer I am looking for -- hope you can help. I have a front-end MS Access database hooked via a MyODBC link to a MySQL database. A modified...
16
by: shreyansghia | last post by:
Hello, I am a new member and am glad to a part of this forum. I am facing a slight problem while doing time calculations in MS access. I ve prepared a time sheet for my workers. Their regular...
7
by: gkarasiewicz | last post by:
Hello All: I'm trying to calculate total hours worked for each of my staff members but am having difficulties with the IF statement. Basically what i've done thus far is this: B1-A1=C1 ...
1
by: creativedas | last post by:
Hello everyone! I am new to this community. I am developing a software for Internet cafes. I encountered a problem while summing up total time used by several users. I have stated my problem...
6
jamesd0142
by: jamesd0142 | last post by:
Ok i have bashed my head against a wall trying to work out how this is done... please help. i have 2 text boxes with the values: txt1.text = "15:27:06" txt2.text = "1:05:27" Now if...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.