Date Difference

S

Sukh

Another question about dates. I have a database which tracks calls logged on
my database. I have set two fields up which calculate the time the call was
opened and the time the call was closed. I have set up another field which i
would like to calculate the difference between the two dates. I have had a
look at http://www.mvps.org/access/datetime/date0012.htm, however i was
wondering whether there was a way to use a formula which would calculate the
number of hours between the two dates.

Thanks in advance
 
A

Al Camp

Sukh,
Your "Time" fields should contain the complete Date and Time of each
event. (1/9/2006 9:32:37 AM)
Then,
DateDiff("h", [EarlierDateTime], [LaterDateTime])
should yield the difference in hours.
 
S

Sukh

Ok, that works fine, thanks, howver, how would i adjust the formula to show
hours and minutes?

Al Camp said:
Sukh,
Your "Time" fields should contain the complete Date and Time of each
event. (1/9/2006 9:32:37 AM)
Then,
DateDiff("h", [EarlierDateTime], [LaterDateTime])
should yield the difference in hours.
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Sukh said:
Another question about dates. I have a database which tracks calls logged
on
my database. I have set two fields up which calculate the time the call
was
opened and the time the call was closed. I have set up another field
which i
would like to calculate the difference between the two dates. I have had
a
look at http://www.mvps.org/access/datetime/date0012.htm, however i was
wondering whether there was a way to use a formula which would calculate
the
number of hours between the two dates.

Thanks in advance
 
S

Sukh

Ok, that works fine thanks, but how do i amend the formula to show the hours
and minutes between the two dates?

Al Camp said:
Sukh,
Your "Time" fields should contain the complete Date and Time of each
event. (1/9/2006 9:32:37 AM)
Then,
DateDiff("h", [EarlierDateTime], [LaterDateTime])
should yield the difference in hours.
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Sukh said:
Another question about dates. I have a database which tracks calls logged
on
my database. I have set two fields up which calculate the time the call
was
opened and the time the call was closed. I have set up another field
which i
would like to calculate the difference between the two dates. I have had
a
look at http://www.mvps.org/access/datetime/date0012.htm, however i was
wondering whether there was a way to use a formula which would calculate
the
number of hours between the two dates.

Thanks in advance
 
D

Douglas J Steele

You can either determine the total minutes (using DateDiff("n",
[EarlierDateTime], [LaterDateTime]) <-- Note that it's n for miNutes, to
avoid confusion with m for Month), and then do arithmetic on that to convert
to hours and minutes (something like TotalMinutes \ 60 & ":" &
Format(TotalMinutes Mod 60, "00")), or you can take a look at "A More
Complete DateDiff Function" at
http://www.accessmvp.com/djsteele/Diff2Dates.html

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Sukh said:
Ok, that works fine, thanks, howver, how would i adjust the formula to show
hours and minutes?

Al Camp said:
Sukh,
Your "Time" fields should contain the complete Date and Time of each
event. (1/9/2006 9:32:37 AM)
Then,
DateDiff("h", [EarlierDateTime], [LaterDateTime])
should yield the difference in hours.
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Sukh said:
Another question about dates. I have a database which tracks calls logged
on
my database. I have set two fields up which calculate the time the call
was
opened and the time the call was closed. I have set up another field
which i
would like to calculate the difference between the two dates. I have had
a
look at http://www.mvps.org/access/datetime/date0012.htm, however i was
wondering whether there was a way to use a formula which would calculate
the
number of hours between the two dates.

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top