What is the best way to query the database where the data is smaller than the current date and time
SELECT * FROM agenda WHERE agendamento < '".date('Y-m-d H:m:s')."'
What is the best way to query the database where the data is smaller than the current date and time
SELECT * FROM agenda WHERE agendamento < '".date('Y-m-d H:m:s')."'
You can use the MySQL
function itself.
If your column has time:
SELECT *
FROM agenda
WHERE agendamento < NOW()
Returns the current date and time as a value in 'YYYY-MM-DD HH: MM: SS' or 'YYYYMMDDHHMMSS' format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone.
Free translation:
Returns the current date and time as the value in the format 'YYYY-MM-DD HH: MM: SS' or YYYYMMDDHHMMSS, depending on the context in which the function is used (string or numeric). The value is expressed in
time zone
current.
If your column is just a date:
SELECT *
FROM agenda
WHERE agendamento < CURDATE()
Returns the current date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numerical context.
Free translation:
Returns the current date as the value in the format 'YYYY-MM-DD' or YYYYMMDD, depending on the context in which the function is used (string or numeric).
$today = date("d/m/Y");
$dia = date("d");
$mes = date("m");
$ano = date("Y");
$total = 0;
function selectAllPessoa(){
$banco = abrirBanco();
$sql = "SELECT * FROM agenda WHERE status = 'N' AND(DAY(data_consulta)='$dia') AND (MONTH(data_consulta)) ORDER BY nome";
I have done this for years but in my code stopped fncionar try there1