Im having a problem converting a datetime which is in string format but I am not able to convert it to DateTime format.
i have the error:
the string was not recognized as a valid datetime. there is an unknown word starting at index 3
because i read an .xmls document with date string 17-ago-18
i think is something like "dd-MMM-yy"
someone can help me to solve this?
my code is:
public JsonResult Pedidos(List<string[]> lines)
{
using (TransactionScope scope = HelperTransactionScope.getTransactionScope())
{
try
{
for (int i = 1; i < lines.Count; i++)
{
if (lines[i].Length == 1)
return Json("400");
PedidosFundilag pedido = new PedidosFundilag();
pedido.Cliente = lines[i][0];
pedido.Division = lines[i][1];
pedido.NumParte = lines[i][2];
pedido.Cantidad = Convert.ToInt32(lines[i][3]);
pedido.FechaSolicitud = Convert.ToDateTime(lines[i][4]);
pedido.FechaEnvio = Convert.ToDateTime(lines[i][5]);
pedido.OrdenCompra = lines[i][6];
pedido.NumConfirmacion = lines[i][7];
AgregarPedido(pedido);
}
scope.Complete();
return Json("200");
}
catch(Exception ex)
{
ModelState.AddModelError("", ex.InnerException == null ? ex.Message : ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : ex.InnerException.Message);
return Json(ex.Message, "400");
}