Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Comparing dates/times

Hi everybody,

In my Access DB I've stored system dates. I would like to be able to compare those dates/time to the current system date/time to see how much time has elapsed. I'm looking for a five hour difference.

Can anyone suggest how to do this in VB, i.e. what data types I would need and even what the calculation may be?

Thanks for your help!
[385 byte] By [scott0_1] at [2007-11-11 10:31:15]
# 1 Re: Comparing dates/times
scott0_1,

Assuming you have retrieved a data/time value from the database and stored it in a variable d1 of type DateTime, to get the difference in hours between d1 and the current date and time:

Now.Subtract(d1).TotalHours

Kerry Moorman
kmoorman at 2007-11-11 20:47:26 >