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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.