简体   繁体   中英

Subtracting two values in SQL Case Statement

I need to subtract two values I am calculating on the fly in a case statement but I cant seem to get it done. Here is what I am trying to do and the error I get is "Incorrect syntax near the keyword END':

[Date] = 
  CASE 
    WHEN [col] = 'YES' 
    THEN CONCAT(MONTH(AnniversaryDate),'/',DAY(AnniversaryDate),'/',(YEAR(GETDATE()) + (YEAR(GETDATE()) - YEAR(AnniversaryDate)))
    END,

Should I instead store the difference in some other column rather than calculate the subtraction where I am currently calculating it?

Thank you!

您缺少右括号。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM