DateDiff

Natasha

Registered User.
Local time
Today, 11:08
Joined
Oct 31, 2001
Messages
10
Hello,

I am using the datediff function to find the number of hours between two dates.

However, if possible I'd like to calculate the minutes as well.

i.e my code is TxtBox3.Value = DateDiff("h", TxtBox1, TxtBox2, VbMonday)

Obviously, I know the problem is due to the "h", and I've looked at the help to find out "n" is minutes, but I'm not sure what the exact format to use is.

Thank you for any help you can offer.

Natasha.
 
Hi Pat,

Many Thanks for your response.

I have done as you suggest, and it almost works.

What now happens is as follows :

I have date/time (all in one box), then I have an hours between box and a minutes between box.

Lets say box 1 is 01/01/01 09:00
and also box 2 is 01/01/01 11:30

the difference is correctly calculated as 150 minutes, however, the hours difference box rounds up to 3 hours (instead of 2)

Is there any way I can get round this ?

Thank you in advance.

Natasha.
 
If you are not declaring "TxtBoxHours" as an Integer in your code then you need to do this or use:

TxtBoxHours = Int(TotMinutes \ 60) 'return hours as integer
 
LOL ... i did not even notice the direction of the slash .... sorry Pat.

RDH
 

Users who are viewing this thread

Back
Top Bottom