I am trying to filter payroll dates where the result will show me ‘2011-12-25’ plus every 14 days after that up until today.
The query I have is:
SELECT trxbegdt FROM UPR30300
WHERE TRXBEGDT <= getdate() and trxbegdt >= DATEADD( DAY ,14, '2011-12-25')
group by trxbegdt
order by TRXBEGDT desc
The problem I am having is that the results show dates that are outside of the 14 day intervals which aren’t normal payroll transaction begin dates. Would anyone have a solution to comply my conditions?
Hows this? This uses a recursive CTE to create the list of valid payroll dates, and then joins that to the real table…