Wednesday, November 02, 2005 8:53:15 PM UTC :: Filed Under ASP.NET

Sample comparing two dates:

Dim t1 As String = DateTime.Parse("3:30 PM").ToString("t")
Dim t2 As String = DateTime.Now.ToString("t")
If DateTime.Compare(DateTime.Parse(t1), DateTime.Parse(t2)) < 0 Then 
     Response.Write(t1.ToString() & " is < than " & t2.ToString())
Else 
     Response.Write(t1.ToString() & " is > than " & t2.ToString())
End If

Sample comparing two moments in time:

Dim adate As DateTime = DateTime.Parse("06/24/2003") 
Dim bdate As DateTime = DateTime.Parse("06/28/2003")
Dim ts As New TimeSpan(bdate.Ticks - adate.Ticks)
Response.Write(ts.TotalDays & "<br>")
Response.Write(ts.TotalHours & ":" & ts.TotalMinutes & _
        ":" & ts.TotalSeconds & ":" & ts.TotalMilliseconds) 
Comments are closed.
Navigation
On this page....
Search
Archives
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Categories
Contact me
Send mail to the author(s) Contact Todd M. Taylor