DateDiff Trouble.

elsanto

Aspiring to Sainthood...
Local time
Tomorrow, 02:02
Joined
Jul 9, 2003
Messages
35
Greetings and Salutations all!

I have a question here that, whilst being DateDiff related, isn't like anything else I can find in the forums. If it's already been answered and I missed it, my apologies.
Otherwise, here it is:

Four fields:
Date In (dd/mm/yy)
Time In (hh:nn)
Date Out (dd/mm/yy)
Time Out (hh:nn)

I need to calculate the hh:nn between the Date and Time In and the Date and Time Out. However, the fields have to initially be separate for data entry purposes.
So I need to combine the Date/Time fields for In and then Out, and calculate the difference in hh:nn format.
Any suggestions?
Cheers.
 
elsanto,

Code:
Dim TotalMinutes As Long
Dim TotalHours As Long

TotalMinutes = DateDiff("n", Me.DateIn & " " & Me.TimeIn, Me.DateOut & " " & Me.TimeOut)

TotalHours = TotalMinutes / 60
TotalMinutes = TotalMinutes - (TotalHours * 60)

Wayne
 
Thanks Wayne,

I just figured out how to do it via a query and was about to post the solution.
Your coding looks easier, so I'll give that a go too.
Cheers.
 
?format(#15-08-2003# + #23:00# - (#16-08-2009#+#01:00#),"HH:MM")
Gives 02:00

Replacing the fields for the values should give you a one line solution...

Regards

The Mailman
 

Users who are viewing this thread

Back
Top Bottom