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

Time-keeping with Access 2000

I have a very simple db I use for keeping track of hours, tasks, projects,
clients etc. It has a form that I use to enter data. Currently the form has
a textbox for a field called "start time", another for a field called "end
time" and a third for a field called "hours", among other controls. I now
type in the approximate times in the first two textboxes, and mentally
calculate and enter the difference or elapsed time in the third.

I have tried to automate the completion of this third field with no luck. I
have tried entering an expression in the control source field of the text
box. I have tried stuff like "=[end time]-[start time]" and "=([end
time]-[start time]*24)" but I'm clearly lost. The first two textboxes are
formatted for "short time". "hours" is formatted as a "general number".

I would like to have the completion of the first two textboxes yield their
difference in the "hours" field in the underlying table, and display in the
form textbox associated with this field. Some other considerations are:

Spanning midnight shouldn't be a problem.

I would like to round the hours to the nearest quarter, since I'm
approximating the time anyway.

I would appreciate any help anyone could extend. One more thing: is possible
to get a control (button) to record the current time in a field?
TIA
--

MichaelB
www.michaelbulatovich.com

Nov 12 '05 #1
6 2708
For basic info on how to calculate the difference between two date/time
fields, see:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

For rounding to the nearest 15 minutes, use:
15 * Round([Minutes] / 15, 0)

In your table, store the starting time and EITHER the ending time OR the
duration. Storing both violates a basic rule of data normalization. The
other one can be calculated in a query, as explained in the article above.

To pop the current time into a text box named "StartTime":
Me.[StartTime] = TimeValue(Now())
Omit the TimeValue() if you want the date as well.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Michael Bulatovich" <Pl****@dont.try> wrote in message
news:nf*********************@news20.bellglobal.com ...
I have a very simple db I use for keeping track of hours, tasks, projects,
clients etc. It has a form that I use to enter data. Currently the form has a textbox for a field called "start time", another for a field called "end
time" and a third for a field called "hours", among other controls. I now
type in the approximate times in the first two textboxes, and mentally
calculate and enter the difference or elapsed time in the third.

I have tried to automate the completion of this third field with no luck. I have tried entering an expression in the control source field of the text
box. I have tried stuff like "=[end time]-[start time]" and "=([end
time]-[start time]*24)" but I'm clearly lost. The first two textboxes are
formatted for "short time". "hours" is formatted as a "general number".

I would like to have the completion of the first two textboxes yield their
difference in the "hours" field in the underlying table, and display in the form textbox associated with this field. Some other considerations are:

Spanning midnight shouldn't be a problem.

I would like to round the hours to the nearest quarter, since I'm
approximating the time anyway.

I would appreciate any help anyone could extend. One more thing: is possible to get a control (button) to record the current time in a field?

Nov 12 '05 #2
DateDiff is a built-in function to calculate date and time differences. The
Date/Time field or variable is for holding a "point in time" -- not a
"period of time", and trying to use it for the latter will, sooner or later,
lead to frustration and problems.

I suggest you use DateDiff to calculate the span of time in a unit of time
of your choosing, and store that in a numeric variable appropriate for the
time periods you are dealing with.

Larry Linson
Microsoft Access MVP
"Michael Bulatovich" <Pl****@dont.try> wrote in message
news:nf*********************@news20.bellglobal.com ...
I have a very simple db I use for keeping track of hours, tasks, projects,
clients etc. It has a form that I use to enter data. Currently the form has a textbox for a field called "start time", another for a field called "end
time" and a third for a field called "hours", among other controls. I now
type in the approximate times in the first two textboxes, and mentally
calculate and enter the difference or elapsed time in the third.

I have tried to automate the completion of this third field with no luck. I have tried entering an expression in the control source field of the text
box. I have tried stuff like "=[end time]-[start time]" and "=([end
time]-[start time]*24)" but I'm clearly lost. The first two textboxes are
formatted for "short time". "hours" is formatted as a "general number".

I would like to have the completion of the first two textboxes yield their
difference in the "hours" field in the underlying table, and display in the form textbox associated with this field. Some other considerations are:

Spanning midnight shouldn't be a problem.

I would like to round the hours to the nearest quarter, since I'm
approximating the time anyway.

I would appreciate any help anyone could extend. One more thing: is possible to get a control (button) to record the current time in a field?
TIA
--

MichaelB
www.michaelbulatovich.com

Nov 12 '05 #3
Thanks for your response Allen. I'm an architect with no DB training so I'm
not sure what "data normalization" means. After thinking about it for a
second or two, I think you mean that there is a way that the three fields
could be made to not have the relationship of C=B-A, say when the form isn't
open, and that this could create a problem....
I currently have some queries that go after the "hours" field directly. What
I think you are saying is that a query is a place to do the 'end time minus
start time" work, not the table. I appreciate the advice.

As for the current time entry issue, what you suggest would enter the time
that the new record was made. Could it be done with a button, where you hit
the button and the current time is entered into a target field in the
record?

On the rounding issue, I don't know where/how the line "15 * Round([Minutes]
/ 15, 0)" would be used.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
For basic info on how to calculate the difference between two date/time
fields, see:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

For rounding to the nearest 15 minutes, use:
15 * Round([Minutes] / 15, 0)

In your table, store the starting time and EITHER the ending time OR the
duration. Storing both violates a basic rule of data normalization. The
other one can be calculated in a query, as explained in the article above.

To pop the current time into a text box named "StartTime":
Me.[StartTime] = TimeValue(Now())
Omit the TimeValue() if you want the date as well.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Michael Bulatovich" <Pl****@dont.try> wrote in message
news:nf*********************@news20.bellglobal.com ...
I have a very simple db I use for keeping track of hours, tasks, projects, clients etc. It has a form that I use to enter data. Currently the form has
a textbox for a field called "start time", another for a field called "end time" and a third for a field called "hours", among other controls. I now type in the approximate times in the first two textboxes, and mentally
calculate and enter the difference or elapsed time in the third.

I have tried to automate the completion of this third field with no luck. I
have tried entering an expression in the control source field of the

text box. I have tried stuff like "=[end time]-[start time]" and "=([end
time]-[start time]*24)" but I'm clearly lost. The first two textboxes are formatted for "short time". "hours" is formatted as a "general number".

I would like to have the completion of the first two textboxes yield their difference in the "hours" field in the underlying table, and display in

the
form textbox associated with this field. Some other considerations are:

Spanning midnight shouldn't be a problem.

I would like to round the hours to the nearest quarter, since I'm
approximating the time anyway.

I would appreciate any help anyone could extend. One more thing: is

possible
to get a control (button) to record the current time in a field?



Nov 12 '05 #4
Replies in-line.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Michael Bulatovich" <Pl****@dont.try> wrote in message
news:Ha*********************@news20.bellglobal.com ...
Thanks for your response Allen. I'm an architect with no DB training so I'm not sure what "data normalization" means. After thinking about it for a
second or two, I think you mean that there is a way that the three fields
could be made to not have the relationship of C=B-A, say when the form isn't open, and that this could create a problem....
I currently have some queries that go after the "hours" field directly. What I think you are saying is that a query is a place to do the 'end time minus start time" work, not the table. I appreciate the advice.
Yes. The calcuation is done in the query, whenever you need it.
If it seems better to you to store the duration in minutes (as a Number
field) rather than the EndTime (as a date/time field), that's fine.
As for the current time entry issue, what you suggest would enter the time
that the new record was made. Could it be done with a button, where you hit the button and the current time is entered into a target field in the
record?
Yes: that line of code would go into the Event Procedure of for the Click
event of the command button.
On the rounding issue, I don't know where/how the line "15 * Round([Minutes] / 15, 0)" would be used.
That's up to you. It could be used in the query calculation, or it could be
used when storing the entry.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
For basic info on how to calculate the difference between two date/time
fields, see:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

For rounding to the nearest 15 minutes, use:
15 * Round([Minutes] / 15, 0)

In your table, store the starting time and EITHER the ending time OR the
duration. Storing both violates a basic rule of data normalization. The
other one can be calculated in a query, as explained in the article above.

To pop the current time into a text box named "StartTime":
Me.[StartTime] = TimeValue(Now())
Omit the TimeValue() if you want the date as well.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Michael Bulatovich" <Pl****@dont.try> wrote in message
news:nf*********************@news20.bellglobal.com ...
I have a very simple db I use for keeping track of hours, tasks, projects, clients etc. It has a form that I use to enter data. Currently the form has
a textbox for a field called "start time", another for a field called "end time" and a third for a field called "hours", among other controls. I now type in the approximate times in the first two textboxes, and mentally
calculate and enter the difference or elapsed time in the third.

I have tried to automate the completion of this third field with no luck.
I
have tried entering an expression in the control source field of the text box. I have tried stuff like "=[end time]-[start time]" and "=([end
time]-[start time]*24)" but I'm clearly lost. The first two textboxes are formatted for "short time". "hours" is formatted as a "general
number".
I would like to have the completion of the first two textboxes yield

their difference in the "hours" field in the underlying table, and display in the
form textbox associated with this field. Some other considerations

are:
Spanning midnight shouldn't be a problem.

I would like to round the hours to the nearest quarter, since I'm
approximating the time anyway.

I would appreciate any help anyone could extend. One more thing: is

possible
to get a control (button) to record the current time in a field?

Nov 12 '05 #5
I've got it working! (This reminds me of when I started to learn LISP. It
was so painful, yet gratifying.)

I created two command buttons, on called btnStart and the other btnStop. The
onclick property for both invoke an "event procedure", which are both
basically the same function that you gave me :

Private Sub btnStart_Click()
Me.[start time] = TimeValue(Now())
End Sub
&
Private Sub btnStop_Click()
Me.[end time] = TimeValue(Now())
End Sub

They dump the current time into the appropriate fields in the form and
table. (YAY!) However they do so in the following format :

9:51:14 AM (AAAWW!)

despite the fact that the form textbox is formatted for "Short Time". I will
occasionally be entering time manually in these fields and the format is
more precise than I need. Can I format it for 'military time' and without
seconds somehow? Yesterday I got my queries to calculate the elapsed time
between the two fields when they were completed with my usual data like:

14:30
&
18:45

in the "start time" and "end time" fields, and put it in a field called
"extras". My reports take the "extras" and convert them from minutes to
fractional hours with:

=[extras]/60

in the control source property of a text box. I'm only guessing, but won't
the queries choke on " 9:51:14 AM " if they worked on " 18:45 "? Aren't they
different data types? In the query's field line I have:

Minutes: Sum(DateDiff("n",[start time],[end time]))

which I think you gave me more or less, and delivers time in minutes.

Thanks again for your generosity.
--

MichaelB
www.michaelbulatovich.com
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
Replies in-line.

"Michael Bulatovich" <Pl****@dont.try> wrote in message
news:Ha*********************@news20.bellglobal.com ...
As for the current time entry issue, what you suggest would enter the time that the new record was made. Could it be done with a button, where you hit
the button and the current time is entered into a target field in the
record?


Yes: that line of code would go into the Event Procedure of for the Click
event of the command button.
On the rounding issue, I don't know where/how the line "15 *

Round([Minutes]
/ 15, 0)" would be used.


That's up to you. It could be used in the query calculation, or it could

be used when storing the entry.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
For basic info on how to calculate the difference between two date/time fields, see:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

For rounding to the nearest 15 minutes, use:
15 * Round([Minutes] / 15, 0)

To pop the current time into a text box named "StartTime":
Me.[StartTime] = TimeValue(Now())
Omit the TimeValue() if you want the date as well.


Nov 12 '05 #6
To show only hours and minutes, set the Format property of the text box to:
hh:nn
(Note that you use n for miNutes, as m is for Month.)

If you want to use a 24-hour clock, open the Windows Control Panel, and go
to Regional Options.

Access stores a date/time value as a number where the integer part indicates
the date, and the fractional part the time of day (e.g. .5= noon, .25 =
6am). Regardless of whether the time is shown as 6:00:00 PM or 18:00, it
will still be stored as 0.75 internally, and the math will still work.

As the article pointed out, durations are better converted to a number of
minutes (or seconds or whatever).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Michael Bulatovich" <Pl****@dont.try> wrote in message
news:x0*********************@news20.bellglobal.com ...
I've got it working! (This reminds me of when I started to learn LISP. It
was so painful, yet gratifying.)

I created two command buttons, on called btnStart and the other btnStop. The onclick property for both invoke an "event procedure", which are both
basically the same function that you gave me :

Private Sub btnStart_Click()
Me.[start time] = TimeValue(Now())
End Sub
&
Private Sub btnStop_Click()
Me.[end time] = TimeValue(Now())
End Sub

They dump the current time into the appropriate fields in the form and
table. (YAY!) However they do so in the following format :

9:51:14 AM (AAAWW!)

despite the fact that the form textbox is formatted for "Short Time". I will occasionally be entering time manually in these fields and the format is
more precise than I need. Can I format it for 'military time' and without
seconds somehow? Yesterday I got my queries to calculate the elapsed time
between the two fields when they were completed with my usual data like:

14:30
&
18:45

in the "start time" and "end time" fields, and put it in a field called
"extras". My reports take the "extras" and convert them from minutes to
fractional hours with:

=[extras]/60

in the control source property of a text box. I'm only guessing, but won't
the queries choke on " 9:51:14 AM " if they worked on " 18:45 "? Aren't they different data types? In the query's field line I have:

Minutes: Sum(DateDiff("n",[start time],[end time]))

which I think you gave me more or less, and delivers time in minutes.

Thanks again for your generosity.
--

MichaelB
www.michaelbulatovich.com
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
Replies in-line.

"Michael Bulatovich" <Pl****@dont.try> wrote in message
news:Ha*********************@news20.bellglobal.com ...
As for the current time entry issue, what you suggest would enter the time that the new record was made. Could it be done with a button, where
you
hit
the button and the current time is entered into a target field in the
record?


Yes: that line of code would go into the Event Procedure of for the Click event of the command button.
On the rounding issue, I don't know where/how the line "15 *

Round([Minutes]
/ 15, 0)" would be used.


That's up to you. It could be used in the query calculation, or it could

be
used when storing the entry.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
> For basic info on how to calculate the difference between two

date/time > fields, see:
> Calculating elapsed time
> at:
> http://allenbrowne.com/casu-13.html
>
> For rounding to the nearest 15 minutes, use:
> 15 * Round([Minutes] / 15, 0)
>
> To pop the current time into a text box named "StartTime":
> Me.[StartTime] = TimeValue(Now())
> Omit the TimeValue() if you want the date as well.
>

Nov 12 '05 #7

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...
1
by: davelist | last post by:
I'm guessing there is an easy way to do this but I keep going around in circles in the documentation. I have a time stamp that looks like this (corresponding to UTC time): start_time =...
2
by: Roseanne | last post by:
We are experiencing very slow response time in our web app. We run IIS 6 - windows 2003. I ran iisstate. Here's what I got. Any ideas?? Opened log file 'F:\iisstate\output\IISState-812.log'...
9
by: Ron Adam | last post by:
I'm having some cross platform issues with timing loops. It seems time.time is better for some computers/platforms and time.clock others, but it's not always clear which, so I came up with the...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
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...

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.