Hi, i have a datetime field in my table, I'm just trying to get just the date part of the field in a query, like this:
$xcurfecdig=shell_exec("date +%Y-%m-%d");
$conn=mysqli_connect($host, $user, $password) or die("No se pudo establecer comunicacion");
$db=mysqli_select_db($conn, $basedatos) or die("Error en la base de datos");
$sql1="SELECT * FROM $tabla22 WHERE codreg= '$targetcodreg' and substring(fechordig, 1, 10)='$xcurfecdig' order by id DESC";
$resultado1=mysqli_query($conn, $sql1) or die(mysqli_error($conn));
I tried this function in the mysql console, like this:
select * from infdiario where codreg='02' and substring(fechordig, 1, 10)="2012-04-29"
and It worked, I have one record that match.
but trying to do the same from the php file it doesn't work:
$sql1="SELECT * FROM $tabla22 WHERE codreg= '$targetcodreg' and substring(fechordig, 1, 10)='$xcurfecdig' order by id DESC";
maybe i'm missing something in the code but I can't see it, so my question is:
why my line it doesn't not work from php? do I have some bug in the code?
regards