473,487 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Time Calculation question

6 New Member
I need to be able to figure out how many minutes it takes an employee to perform a set of tasks.

My employees always start thier job at 5AM and complete, say 20 tasks by 7AM, then move to another set of tasks that get completed by say 825AM.

My database already records the number of tasks as a sum. And the time they COMPLETETED the task.

So my reports print out with the employee name, the number of tasks and the time they completed them.

I would like my report to calculate how long it took them to all of thier tasks in total assuming a start time of 5AM and report it in minutes.

So if they started at 5AM and finshed their last task at 8:45, the report would list the times completed and sum the total time as 225 minutes.

What is the code to make this happen?

Then I need to have it tell me how long in minutes it took to complete the total amount of tasks. So in other words if it took 225 minutes to complete 28 tasks I want it to show me that it took 8 minutes per task.

Can anyone help me out with this?

Thanks - I would be grateful.

Ross
Buffalo, NY
Nov 10 '06 #1
3 2918
Andrew Thackray
76 New Member
the function you want is Datediff. This calculates the time between two dates in the units specified. the documentation for the function is



DateDiff Function


Returns a Variant (Long) specifying the number of time intervals between two specified dates.

Syntax

DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

The DateDiff function syntax has these named arguments:

Part Description
interval Required. String expression that is the interval of time you use to calculate the difference between date1 and date2.
date1, date2 Required; Variant (Date). Two dates you want to use in the calculation.
firstdayofweek Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed.
firstweekofyear Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.



Settings

The interval argument has these settings:

Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second



The firstdayofweek argument has these settings:

Constant Value Description
vbUseSystem 0 Use the NLS API setting.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday



Constant Value Description
vbUseSystem 0 Use the NLS API setting.
vbFirstJan1 1 Start with week in which January 1 occurs (default).
vbFirstFourDays 2 Start with the first week that has at least four days in the new year.
vbFirstFullWeek 3 Start with first full week of the year.



Remarks

You can use the DateDiff function to determine how many specified time intervals exist between two dates. For example, you might use DateDiff to calculate the number of days between two dates, or the number of weeks between today and the end of the year.

To calculate the number of days between date1 and date2, you can use either Day of year ("y") or Day ("d"). When interval is Weekday ("w"), DateDiff returns the number of weeks between the two dates. If date1 falls on a Monday, DateDiff counts the number of Mondays until date2. It counts date2 but not date1. If interval is Week ("ww"), however, the DateDiff function returns the number of calendar weeks between the two dates. It counts the number of Sundays between date1 and date2. DateDiff counts date2 if it falls on a Sunday; but it doesn't count date1, even if it does fall on a Sunday.

If date1 refers to a later point in time than date2, the DateDiff function returns a negative number.

The firstdayofweek argument affects calculations that use the "w" and "ww" interval symbols.

If date1 or date2 is a date literal, the specified year becomes a permanent part of that date. However, if date1 or date2 is enclosed in double quotation marks (" "), and you omit the year, the current year is inserted in your code each time the date1 or date2 expression is evaluated. This makes it possible to write code that can be used in different years.

When comparing December 31 to January 1 of the immediately succeeding year, DateDiff for Year ("yyyy") returns 1 even though only a day has elapsed.

Note For date1 and date2, if the Calendar property setting is Gregorian, the supplied date must be Gregorian. If the calendar is Hijri, the supplied date must be Hijri.
Nov 10 '06 #2
NeoPa
32,556 Recognized Expert Moderator MVP
Assuming the field is called datFinishTime and you have a variable intMinutes then,
Expand|Select|Wrap|Line Numbers
  1. intMinutes = 60 * (Hour(datFinishTime) - 5) + Minute(datFinishTime)
I'm not sure you really want someone to tell you how to divide this by the field with the number of tasks in it ;)
Nov 11 '06 #3
Killer42
8,435 Recognized Expert Expert
...
Then I need to have it tell me how long in minutes it took to complete the total amount of tasks. So in other words if it took 225 minutes to complete 28 tasks I want it to show me that it took 8 minutes per task.
Just to expand on a couple of points...
  • If you use DateDiff, make sure you noticed that minutes are represented by n, not m. This trap catches a lot of people.
  • You want ot be careful of your terminology. In the section highlighted above, what you want to know is the average amount of time to complete each task.
Nov 12 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
4671
by: Tom | last post by:
A field in a data set I want to import into Access is in Unix time (seconds from a certain time on a certain date). Does anyone know the precise date and the precise time on that date that Unix is...
0
1715
by: gavo | last post by:
Hi. using A2K; i have a form containing a continous subform. The question is, how can i call a calculation for one of the fields in the continous subform from the main form. At the moment i...
4
2453
by: John | last post by:
Hi I have a start date and a start time field. I also have a timespan value which can be anything from 5 minutes (TimeSpan(0, 5, 0)) to 2 weeks (TimeSpan(14, 0, 0, 0)). How can I get an end date...
3
4562
by: linq936 | last post by:
I have some algorithm dealing with unsigned int calculation a lot, I am trying to add some check for overflow. The initial thinking was very easy, just do something like this, int...
33
7364
by: ram.ragu | last post by:
hi i have problem to calculate idle time of cpu and if idle time is more then i have to shut down the system. can anyone tell me the idea to so that please
8
2311
by: andreas | last post by:
Hi, I have a calculation program in vb.net who is running for let us say for more than a hour. When I will do meanwhile something els in a office program I see that my calculation program takes a...
5
6220
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
5
2569
by: prakashwadhwani | last post by:
I have a button on my (continuous) form which when pressed performs the foll 2 actions: 1) it resets the field "Init_Bal" to 0 2) it computes the closing balances & stores them in the field...
1
1378
by: juliacjy | last post by:
Dear all, I'm needing an urgent help. I'm now maintaining a system which has a function of "Automatic Calculation". User is allowed to set of a time which then will be stored in one of my sql...
6
11432
by: Lara1 | last post by:
I'm trying to get certain cells to show a hovering alert message when I click on them. (I don't want an error-message style box to pop up, because I'll eventually want it to show for lots of cells...
0
7108
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
7142
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
7352
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
5445
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,...
1
4875
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...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.