VBdotnet2005
asked on
timespan
how can I get the different in hr between 10:05:01 AM AND 12:25:05 PM ? I am not sure how to use timespan.
Slight correction:
Use the TotalHours property to get the elapsed hours.
Use the TotalHours property to get the elapsed hours.
ASKER
Sorry, I forgot to ask this. How can I get just the time for today...like 12:21:01 PM
dim timenow as date = now.tostring("hh:mm:ss T")
dim time2 = 10:00:00 AM
dim ts as timespan = timenow - time2 ????
I don't know what you're asking. An elapsed time is not for any specific day.
ASKER
ok in my database, I have a column which stamps time like 10:21:01 PM only. That is what I get the value from.
now, I want to find out the different in hours from that time to the current time.
db = 10:21:01 PM
time right now is 12:38:21 PM
result is 2 hrs. How can I get the different here?
now, I want to find out the different in hours from that time to the current time.
db = 10:21:01 PM
time right now is 12:38:21 PM
result is 2 hrs. How can I get the different here?
? The timespan difference.totalhours would return 2. that IS the difference!
Try this
Dim ts As TimeSpan = New TimeSpan()
Dim ts1 As TimeSpan = TimeSpan.Parse("11:59:39")
Dim ts2 As TimeSpan = TimeSpan.Parse("12:00:05")
ts = ts2.Subtract(ts1)
Dim ts As TimeSpan = New TimeSpan()
Dim ts1 As TimeSpan = TimeSpan.Parse("11:59:39")
Dim ts2 As TimeSpan = TimeSpan.Parse("12:00:05")
ts = ts2.Subtract(ts1)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I agree. I'm not sure what's going on here! :)
Dim hrs As Integer = its.Hours
dtNow is one datetime
dtyest is other datetime