1
I have a problem when passing a date to a select. Using the form below, select me returns the data normally:
SELECT H.* FROM HORARIOS H
WHERE NOT EXISTS (
SELECT * FROM RESERVAS R
WHERE H.COD BETWEEN R.COD_HORA_SAIDA AND
R.COD_HORA_PREVISTA-1 AND
R.COD_VEICULO = 1 AND
R.DATA_SAIDA = '2015-11-26')
ORDER BY H.COD;
But, if I try to pass to the d-m-a format as below, it does not correctly return the data.
SELECT H.* FROM HORARIOS H
WHERE NOT EXISTS (
SELECT * FROM RESERVAS R
WHERE H.COD BETWEEN R.COD_HORA_SAIDA AND
R.COD_HORA_PREVISTA-1 AND
R.COD_VEICULO = 1 AND
DATE_FORMAT(R.DATA_SAIDA, '%d-%m-%Y') = '26-11-2015')
ORDER BY H.COD;
Someone could tell me why he won’t accept it this way?
It would not only be DATE_FORMAT(R.DATA_SAIDA,'%m-%d-%Y') = 26-11-2015' so that the latter ) ?
– Gabriel Rodrigues
the latter is the parameter that comes from PHP. It comes in this dd-mm-yyyy format
– Diego
In the first example this R.DATA_SAIDA, IN THE SECOND DATA_SAIDA ONLY, this is certain ?
– Gabriel Rodrigues
It was a typo, I fixed it.
– Diego
I’m glad it worked out!
– Gabriel Rodrigues