I have a Job in the sql server that runs twice a day, 6:00 p.m. and 6:00 p.m., it has an sql query where I get the process date and compare it to the date of the day. It turns out that if you have a new change after 6:00 PM, they will not be updated because there will be a new date after 12:00 AM. How could I offset this time in hours in the query by adding this result? I could change the schedule of the job plus the client thinks not, that I wanted another solution, I can not see a solution. The c.dtHrProcess field has the date in the format: 2016-11-23 04: 38: 10,307
Segue a consulta
SELECT DISTINCT p.codInterno,
CASE
WHEN f.idFabricante IS NULL THEN 99999999999999
ELSE f.idFabricante
END AS fabri,
'0',
p.descResumida,
p.descProduto,
p.descProduto,
p.codElemento,
GETDATE(),
GETDATE(),
0,
0
FROM [192.168.200.87].[siac].[dbo].[IntPluProduto] p
INNER JOIN [192.168.200.98].[siac].[dbo].[IntControle] c on c.idProcesso = p.idProcesso
LEFT JOIN [192.168.0.150].[tlmark].[dbo].[Produto] vanProduto on vanProduto.CdPrdSAP = p.codInterno
LEFT JOIN tbFabricante f on f.idFabricante = CAST(vanProduto.CdFbr AS INT)
WHERE (select COUNT(*) from tbProduto where idSAP = p.codInterno) = 0
AND vanProduto.cdFbr <> 'NNN0'
AND CAST(c.dtHrProcesso AS DATE) = CAST(GETDATE() AS DATE)
AND c.codModulo = 14
AND vanProduto.ICMSubst <> 'T'