A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

total beginning and ending date



 
 
Thread Tools Display Modes
  #1  
Old February 3rd, 2005, 07:35 PM
Karen
external usenet poster
 
Posts: n/a
Default total beginning and ending date

I have two fields named BegTime and EndTime that are using a default value of
time(). Then I have another field named TotalTime that I would like to have a
total of these two fields. Example 10:00 + 11:00 = 1.0. Does anyone know how
I could do this?

Thanks in advance.

Karen
  #2  
Old February 3rd, 2005, 08:25 PM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Thu, 3 Feb 2005 10:35:07 -0800, "Karen" Karen
@discussions.microsoft.com wrote:

I have two fields named BegTime and EndTime that are using a default value of
time(). Then I have another field named TotalTime that I would like to have a
total of these two fields. Example 10:00 + 11:00 = 1.0. Does anyone know how
I could do this?


I take it that you want the DIFFERENCE of the two times, not the total
- the time elapsed, no?

Take a look at the DateDiff() function. Your "TotalTime" field should
NOT exist in this table, or any other table; since it can be derived
from the BegTime and EndTime values, storing it would be redundant and
unwise. Instead, create a Query based on the table; select the BegTime
and EndTime fields, and in a vacant Field cell type

TotalTime: DateDiff("n", [BegTime], [EndTime]) / 60.

to calculate the time difference in minutes and then divide by 60 to
get fractional hours.

Note that this will not work over midnight; Time() is actually a
date/time value on December 30, 1899. If you'll ever want to span
midnight, you'ld do better to use Now() rather than Time() as the
default, to include both the date and the time.

John W. Vinson[MVP]
  #3  
Old February 3rd, 2005, 10:33 PM
Karen
external usenet poster
 
Posts: n/a
Default

Thank you so much. That points me in the right direction. I had no idea how
to even begin.

"John Vinson" wrote:

On Thu, 3 Feb 2005 10:35:07 -0800, "Karen" Karen
@discussions.microsoft.com wrote:

I have two fields named BegTime and EndTime that are using a default value of
time(). Then I have another field named TotalTime that I would like to have a
total of these two fields. Example 10:00 + 11:00 = 1.0. Does anyone know how
I could do this?


I take it that you want the DIFFERENCE of the two times, not the total
- the time elapsed, no?

Take a look at the DateDiff() function. Your "TotalTime" field should
NOT exist in this table, or any other table; since it can be derived
from the BegTime and EndTime values, storing it would be redundant and
unwise. Instead, create a Query based on the table; select the BegTime
and EndTime fields, and in a vacant Field cell type

TotalTime: DateDiff("n", [BegTime], [EndTime]) / 60.

to calculate the time difference in minutes and then divide by 60 to
get fractional hours.

Note that this will not work over midnight; Time() is actually a
date/time value on December 30, 1899. If you'll ever want to span
midnight, you'ld do better to use Now() rather than Time() as the
default, to include both the date and the time.

John W. Vinson[MVP]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
printing calender with beginning and ending times Lory Calendar 0 September 28th, 2004 06:05 AM
Eliminate information at beginning and ending Craig General Discussion 2 July 27th, 2004 05:48 PM


All times are GMT +1. The time now is 03:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.