I have had a quick look around and I can't find an answer to this in vb.net or something that I can convert into vb.net.
I have two DateTimes in vb.net's 'Date' class. I would like to find the difference between these in seconds. I can do a-b, but the answer will still be a 'date'. I can use .seconds
.minutes
etc. and multiply but I will hit problems when I come to months.
Is there a simple way to do this, or do I need to write some elaborate-ish code?
Many Thanks
Subtract the DateTime
values from each other - the returned type will be a TimeSpan
.
Get the TotalSeconds
value from it.
(date1 - date2).TotalSeconds
There actually is also a function made for this DateDiff(DateInterval.Second, d1, d2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With