6
I’m trying some alternatives to show only the records of the last 30 days, but I couldn’t make it work, the query I have is like this:
SELECT comunidade.descricao AS nomeunidade
,comcargo.descricao AS nomecargo
,comcolaborador.nome
,date_format(comcolaborador.dtadmissao,'%d/%m/%Y') AS dataadm
,comcolaborador.foto
,comcolaborador.idcargo
,comcolaborador.idunidade
,comcolaborador.login
FROM comunidade
INNER JOIN comcolaborador
ON comunidade.idunidade = comcolaborador.idunidade
INNER JOIN comcargo
ON comcolaborador.idcargo = comcargo.idcargo
WHERE comcolaborador.ativo = 1
AND comcolaborador.dtadmissao >= '2016-08-01'
AND comunidade.ativo = 1
AND comcargo.ativo = 1
ORDER BY comcolaborador.dtadmissao DESC
And what I tried was this, following a few tips and suggestions:
WHERE data >= dateadd(minute,-30,getdate())
Just for the record:
getdate()
, if memory serves, it does not exist in Mysql. It works only in SQL Server.– Sorack
Just as Sorack commented, the equivalent of
getdate
in theMySQL
, is:curdate
ornow
– Marcelo de Andrade