我有一个使用 Windows 调度程序自动运行的程序。该程序所做的是运行“昨天”结果的查询......然后过滤结果,不包括特定时间范围内的任何内容。我现在遇到的问题是我必须在查询中指定日期......我怎样才能让查询自动排除时间(早上 5:30 到早上 6:15)
SELECT Store_Id, DM_Corp_Received_Date
FROM Register_Till_Count_Tb
WHERE (DM_Corp_Received_Date >= DATEADD(day, DATEDIFF(day, 0, GETDATE()) - 1, 0))
AND (Register_Transaction_Type = 'sod')
AND (DM_Corp_Received_Date < DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0))
AND (DM_Corp_Received_Date NOT BETWEEN CONVERT(datetime, '2012-08-08 05:30:00', 102) AND CONVERT(Datetime, '2012-08-08 06:15:00', 102))