Charmer (2/8/2016)
OMG,I am sorry, Chris. The script is still wrong.
Just see the screen shot attached in here. The ID 4, having startdate '2016-01-27' should show '2016-01-26'
instead of '2016-01-27'. because we have '2016-01-26' is the minimum date to '2016-01-27'
Easy enough - correct your scripts. Also, rather than using GETDATE() and arithmetic, use hardcoded date values.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden