I'm working on adding a column to a temp table. I'd like it to be true/false. I would like to condition it from the field called CDTxnDate. (If the difference between the two dates is more than one month, then true, else false.) For now I've tried to simplify by just putting a static date in my datediff statement.
Here's the simplified version of what I'm TRYING to do:
Here's what I'd eventually LIKE to do:
I can't seem to figure out how to do this. Can anyone help me out and point me in the right direction? Thanks!
Here's the simplified version of what I'm TRYING to do:
Code:
SELECT
*,RentalDaysOverMonth = 0
IF (SELECT DATEDIFF(Month,'1/1/2007',GETDATE())) > 0 THEN RentalDaysOverMonth = 1 ELSE RentalDaysOverMonth = 0 END
FROM ##TempOutstandingCylinders cd
ORDER BY CDFranchise,CDCustName,RentalDaysOverMonth
Here's what I'd eventually LIKE to do:
Code:
SELECT
*,RentalDaysOverMonth = 0
IF (SELECT DATEDIFF(Month,[highlight]cd.CDTxnDate[/highlight],GETDATE())) > 0 THEN RentalDaysOverMonth = 1 ELSE RentalDaysOverMonth = 0 END
FROM ##TempOutstandingCylinders cd
ORDER BY CDFranchise,CDCustName,RentalDaysOverMonth
I can't seem to figure out how to do this. Can anyone help me out and point me in the right direction? Thanks!