Live Chat Icon For mobile
Live Chat Icon

How to validate that a string is a valid date?

Platform: ASP.NET| Category: Basic

VB.NET


Dim blnValid As Boolean = False
Try
   	DateTime.Parse(MyString)
	blnValid = True
Catch
	blnValid = False
End Try

C#


bool blnValid=false;
try
{
   	DateTime.Parse(MyString);
   	blnValid=true;
}
catch
{
   	blnValid=false;
}

Share with

Share on twitter
Share on facebook
Share on linkedin