Time difference giving incorrect results vb 6

isnoend2001
isnoend2001 used Ask the Experts™
on
Dim Time As String
Time = "09:58 AM"

Minutes = DateDiff("n", Time, Format(Now, "short time"))
when ran at 8:57PM
the minutes say 661, but should be 780
what is wrong ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and Programming
Top Expert 2015

Commented:
try using different variable names, especially for Time as that is a reserved word
byundtMechanical Engineer
Most Valuable Expert 2013
Top Expert 2013

Commented:
Between 9:58 AM and 8:57 PM, it is one minute shy of 11 hours. I think the difference should be 659 minutes. Why do you think it ought to be 780?

Just for grins, I ran the code in Excel VBA, and it agreed with my arithmetic expectations.

Author

Commented:
Between 9:58 AM and 8:57 PM, it is one minute shy of 11 hours. I think the difference should be 659 minutes. Why do you think it ought to be 780?
when ran at 8:57PM is about 13 hours from 9:58Am
13x60 = 780 minutes
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
try using different variable names, especially for Time as that is a reserved word
i will give it a try, good thought
byundtMechanical Engineer
Most Valuable Expert 2013
Top Expert 2013

Commented:
I disagree. 13 hours would be 10:58 PM.

Surely you would agree that 9:58 AM to 9:58 PM would be exactly 12 hours. And 9:58 PM to 9:58 AM the next day would be another 12 hours.
Mechanical Engineer
Most Valuable Expert 2013
Top Expert 2013
Commented:
The only way to get 13 hours would be if you wanted the difference between 8:58 PM today and 9:58 AM tomorrow. And to get that, you would need to reverse the parameters in DateDiff.
Minutes = DateDiff("n", Format(Now, "short time"), CDate(Time) + 1)

Author

Commented:
try using different variable names, especially for Time as that is a reserved word
changed Time to ITime
made no difference

Author

Commented:
Thanks that fixed the issue

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial