This code helps to Compare Time Using C# or VB.NET
C# Code:
string t1 = DateTime.Parse("3:30 PM").ToString("t");
string t2 = DateTime.Now.ToString("t");
if (DateTime.Compare(DateTime.Parse(t1), DateTime.Parse(t2)) <>
{
Response.Write(t1.ToString() + " is <> + t2.ToString());
}
else
{
Response.Write(t1.ToString() + " is > than " + t2.ToString());
}
VB.NET Code:
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)) < style="color:blue">Then
Response.Write(t1.ToString() & " is <> & t2.ToString())
Else
Response.Write(t1.ToString() & " is > than " & t2.ToString())
End If
nice it works for me..Many thanks
ReplyDelete