在某种情况下,我需要返回当月特定日期之后加载的所有记录,从某种意义上讲,是该月的截止日期。
在我的情况下,我需要在当月的第9天之后返回所有值。
答案 0 :(得分:0)
DECLARE @CUTOFFDAY INT
DECLARE @CUTOFFDATE DATETIME
SET @CUTOFFDAY = 9
SET @CUTOFFDATE = CAST(CAST(YEAR(getdate()) AS varchar) + '-' + CAST(MONTH(getdate())AS varchar) + '-' + CAST(@CUTOFFDAY AS varchar) AS DATETIME)
SELECT Date
FROM DateTable
WHERE ContractDate > @CUTOFF
DATE
答案 1 :(得分:0)
declare @cutoffday int = 9
select * from <yourtable>
where <yourdatefield> >=
dateadd(m, datediff(m, 0, current_timestamp), @cutoffday - 1)