I am trying to take the year part from one date column and year part from another date column and subtract the two. from there i'm trying to filter by the result. Greater than zero. The error i get is: "Adding a value to a 'date' column caused an overflow".
the [total amount] divided by [fee amount] which gives number of years. The fee amount is paid every year, which tells us number of years when total will be paid off. i want to add the years to the "from_Startdt" and subtract current year. for the formula to work. so if the difference is less that zero to exclude these records. meaning total has been paid off. any insight is very much appreciated!
here's what i tried:
SELECT * from
( SELECT * FROM table.1 WHERE Year(DateAdd(Year,([Total_Amount]/[Fee_Amount]),[from_Startdt]))-Year(Getdate())as difference ) as comb WHERE comb.difference >= 0
You can't create an alias in the
WHEREclause.