4
I have a problem trying to modify the type of date that appears to me in two columns of a table of mine.
This is my code:
declare @top10reclamacoes varchar(max)
declare @html varchar(max)
declare @numero_reclamacoes_abertas_mes integer
declare @numero_reclamacoes_fechadas_mes integer
declare @startofcurrentmonth datetime
SELECT CONVERT(DATETIME, R.Data, 111) AS Data
FROM Reclamacoes R
SELECT @numero_reclamacoes_abertas_mes = count(*)
FROM Reclamacoes R
WHERE R.Data >= DATEADD(month, -1, @startOfCurrentMonth)
set @html = '<html>
<body>
<font face="verdana" size="6"><b><u><center>INFORMAÇÃO PARA TODA A EMPRESA</center></u></b></font><br>
<br>
<font face ="verdana "size="5"><b><center>Número reclamações abertas este mês:' + convert(varchar(50), @numero_reclamacoes_abertas_mes)
SELECT @numero_reclamacoes_fechadas_mes = count(*)
FROM Reclamacoes R
WHERE R.DataConclusao >= DATEADD(month, -1, @startOfCurrentMonth)
And Tratado = 1
set @html = @html + '<br><br>Número reclamações fechadas este mês:' + convert(varchar(50), @numero_reclamacoes_fechadas_mes)
Select top 10 @html = @html + '<tr><td>' + convert(nvarchar(50), ID) + '</td><td>' + convert(datetime, R.Data) + '</td><td>' + ISNULL(convert(nvarchar(50),DataConclusao) , '') + '</td><td>' + convert(nvarchar(max), Exposicao) + '</td><td>' + convert(nvarchar(50), Tratado) + '</td></tr>'
From Reclamacoes R
Order by R.Data ASC
set @html = @html + '</html></table>'
print @html
Where are the fields R.Data
and R.DataConclusao
, the format of the date type is 2018-11-27 00:00:00.0000000
and what I want is 2018-11-27
.
Can anyone help me? Thanks in advance.
and how do I put this into practice? can you help me? blz
– Miguel Meireles
@Miguelmeireles tests the code I put in the answer you will understand how to use
– Sorack
grateful for your help, thanks.
– Miguel Meireles