From the reading of an Excel spreadsheet I receive the following information:
To validate this data I do:
(I configure the cultural info to transform the date, I already tried "en-US", "es-ES", "es" and "es-AR")
System.Globalization.CultureInfo cInfo = new System.Globalization.CultureInfo("es-AR");
try
{
DateTime dt = Convert.ToDateTime(sFecha, cInfo); //sFecha es alguno de los valores anteriormente mencionados
}
catch
{
//informo que el dato no respeta el formato de fecha
}
With the System.Globalization.CultureInfo "es-AR" All the cases work for item 1. "01-Mar-2017" (I do not understand why it should work), the dates of March do not convert them, but if I change the System.Globalization.CultureInfo to the "en-US" if it converts the dates of March but when an August date arrives it obviously does not walk (August = August in English).
Someone could share some way in which you can validate these dates using the DateTime (I can verify the format of the chain and check it by analyzing each character, but I suppose there should be a kinder way to do it)
DateTime.TryParse
DateTime.TryParse does not work, it converts "0" to a date.