Time difference giving incorrect results vb 6

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 ?
isnoend2001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
try using different variable names, especially for Time as that is a reserved word
byundtMechanical EngineerCommented:
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.
isnoend2001Author 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
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

isnoend2001Author Commented:
try using different variable names, especially for Time as that is a reserved word
i will give it a try, good thought
byundtMechanical EngineerCommented:
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.
byundtMechanical EngineerCommented:
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)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isnoend2001Author Commented:
try using different variable names, especially for Time as that is a reserved word
changed Time to ITime
made no difference
isnoend2001Author Commented:
Thanks that fixed the issue
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.