I have another problem at the moment of wanting to make the modification of the file, I have in the same table the years 2016 and 2017 with the regristers that start from 1 to ... x number, the problem is that the Id are repeated if the year begins, then I am trying to sort by date so that I take the most recent and so, the detail is that if I tell you to update me through IdExpediente = '". $ id, I modified the two years, then I've been thinking and I think the solution is to tell them to fit them per year and update me only those of 2017 and not those of last year, I present the code that I have been trying to modify but the syntax is where I fail, I do not know if they can guide me on how to go.
$sql = "UPDATE tExpedientes
SET Descripcion='".$descripcion."',
Fecha='".$fecha."',
IdEstatus='".$estado."',
IdAutoridad='".$autoridad."',
QuejosoNombre='".$quejosoNombre."',
QuejosoApellidos='".$quejosoApellidos."',
IdConceptoViolacion='".$conceptoViolacion."',
ServidorPublico='".$servidorPublico."',
TipoAutoridad='".$tipoAutoridad."',
IdTipo='".$tipoExpediente."',
IdTurnadoA='".$turnadoA."'
WHERE IdExpediente='".$id "' ORDER BY fecha DESC, IdExpediente DESC"
$version = sqlsrv_query($conn, $sql);