Thanks Jay! That answered my question.
I have a follow-up question, and that is how can I add up the time periods
of the format "HH:mm:ss" and report the result in the same format?
"Jay B. Harlow [MVP - Outlook]" wrote:
Amjad
I normally use DateTime.Subtract to subtract dates:
Dim date1 As DateTime = #10:30:00 AM#
Dim date2 As DateTime = #9:30:00 AM#
Dim ts As TimeSpan = date1.Subtract(date2)
To get to hh:mm:ss specifically (or other custom date/time formats) I
normally convert the TimeSpan to a date.
Dim r As DateTime = DateTime.MinValue.Add(ts)
Dim s As String = r.ToString("hh:mm:ss")
TimeSpan.ToString will optionally include any days & fraction of seconds in
the converted value.
NOTE: You need to make sure the TimeSpan is positive for the
DateTime.MinValue.Add method to work.
Hope this helps
Jay
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com...
|I want to subtract two Date variables and show the result in this format:
| hh:mm:ss
|
| I'm thinking that there might be an easy way of doing that. something
like:
| ...
| Return DateDiff(DateInterval.Second, date1, date2).ToString("hh:mm:ss")
| ...
|
| Is there such an easy way of doing this?