Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
ASP.NET: Calculate the difference between two dates
From Wiki
Summary: An example of how you can use the TimeSpan class to measure the difference between two dates.
Need help with ASP.NET? Come and ask a question in our ASP.NET Forum
- Dim d1 As Date = CDate("2007-12-01")
- Dim d2 As Date = CDate("2007-12-11")
- Dim t As New TimeSpan
- t = d2.Subtract(d1)
- Response.Write("Days: " & t.Days & "<br>")
- Response.Write("Hours: " & t.Hours & "<br>")
- Response.Write("Minutes: " & t.Minutes & "<br>")
- Response.Write("Seconds: " & t.Seconds & "<br>")
- Response.Write("Total Days: " & t.TotalDays & "<br>")
- Response.Write("Total Hours: " & t.TotalHours & "<br>")
- Response.Write("Total Minutes: " & t.TotalMinutes & "<br>")
- Response.Write("Total Seconds: " & t.TotalSeconds & "<br>")
This Hack is part of the ASP.NET Hacks collection



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.