time difference

C

Clan McCreery

Hello, I'm trying to get the time difference in
hours:minutes between to "short date" fields. I was told
I could use the DateDiff function in my query:

(DateDiff("hh:nn", TimeIn, TimeOut))

All I get is an error. Any ideas please?

Thanks!

Clan McCreery
 
D

Douglas J. Steele

DateDiff can only one unit: it'll give you the difference in Minutes, or it
will give you the difference in Hours, but it can't do both.

You could use it to give you the difference in Minutes, and then convert
minutes to hours and minutes, using something like the following untested
air-code:

Function FormatTimeInMinutes(MinutesIn As Long) As String

FormatTimeInMinutes = MinutesIn\60 & ":" & _
Format$(MinutesIn Mod 60, "00")

End Function

Another possibility is to use the Diff2Date function Graham Seach and I
wrote. Check http://members.rogers.com/douglas.j.steele/Diff2Dates.html
 
D

Denise aka Clan McCreery

Thanks - I tried the code from the page you suggested
using the "hns" and I still got an error. Whenever I try
to get "hns" whether thru your code or the standard
datediff code, my db shuts down and sends an error report
to MS. :-( My client must have hour,minute.....I'll try
your air-code next. Thanks again...Denise
 
D

Douglas J. Steele

There could be something wrong with your database: I've never heard of a
problem with that code.

Try creating a new database, and importing all of the objects from your
existing database into it.
 

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

Similar Threads

DatePart 1
Net Work Days in Access? 1
Time Conversions 2
Time Calculations 5
Iif Query 5
Date Time Group Math 3
Sum and Avg with DateDiff 7
Calculating hours on a timeclock form 7

Top