Hi telldurges,
Refer below code.
C#
string date = "06.20.2020";
string[] validformats = new[] { "MM-dd-yyyy", "MM/dd/yyyy","MM.dd.yyyy",
"dd-MM-yyyy","dd/MM/yyyy", "dd.MM.yyyy" ,
"yyyy-MM-dd","yyyy/MM/dd", "yyyy.MM.dd" ,
"yyyy-dd-MM","yyyy/dd/MM", "yyyy.dd.MM" };
System.Globalization.CultureInfo provider = new System.Globalization.CultureInfo("en-US");
try
{
DateTime dateTime = DateTime.ParseExact(date, validformats, provider, System.Globalization.DateTimeStyles.None);
Response.Write("The specified date is valid: " + dateTime);
}
catch (FormatException ex)
{
Response.Write("Unable to parse the specified date");
}
VB.Net
Dim date As String = "06.20.2020"
Dim validformats As String() = {"MM-dd-yyyy", "MM/dd/yyyy", "MM.dd.yyyy", "dd-MM-yyyy", "dd/MM/yyyy", "dd.MM.yyyy", "yyyy-MM-dd", "yyyy/MM/dd", "yyyy.MM.dd", "yyyy-dd-MM", "yyyy/dd/MM", "yyyy.dd.MM"}
Dim provider As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US")
Try
Dim dateTime As DateTime = DateTime.ParseExact(date, validformats, provider, System.Globalization.DateTimeStyles.None)
Response.Write("The specified date is valid: " & dateTime)
Catch ex As FormatException
Response.Write("Unable to parse the specified date")
End Try