Working with Dates in ASP.NET

.NET makes working with dates incredibly easy. To find the difference between two dates, simply subtract them like subtracting two integers. The result of the operation is a timespan object.

Dim dt1 As DateTime = Now
Dim dt2 As DateTime = dt1.AddDays((New Random).NextDouble() * 2)
Dim ts As TimeSpan = dt2 - dt1
lblDates.InnerHtml = dt2 & " minus " & dt1
lblDays.InnerHtml = ts.Days
lblHours.InnerHtml = ts.Hours
lblMinutes.InnerHtml = ts.Minutes
lblSeconds.InnerHtml = ts.Seconds
lblMillisec.InnerHtml = ts.Milliseconds
lblTotalHours.InnerHtml = ts.Days * 24 + ts.Hours + ts.Minutes / 60
lblTotalMinutes.InnerHtml = ts.Days * 24 * 60 + ts.Hours * 60 + ts.Minutes

DATES: 12/11/2018 6:18:52 AM minus 12/10/2018 1:16:19 AM
DAYS: 1
HOURS: 5
MINUTES: 2
SECONDS: 32
MILLISECONDS: 979
Total Hours: 29
Total Minutes: 1742