0

I am trying to set a condition to a field in sp

If SI0_ADDR.ADDR_EXPR_DATE = '1001-01-01' or > currentDate(), display address active flag = 'Y', else display 'N'.

I am trying this

case [ADDR_EXPR_DATE]
  when '1001-01-01'||[ADDR_EXPR_DATE] > getdate()  then 'Y'
  when  > (getdate()) then 'N'
  else 'N'
end as active_flag 
3
  • pls ignore the 3rd row in the code Commented Nov 13, 2015 at 21:15
  • try cast('1001-01-01' as date) Commented Nov 13, 2015 at 21:16
  • I believe my latest edit to my answer is what you are looking for. Commented Nov 13, 2015 at 21:22

1 Answer 1

3

This: || is not valid in SQL Server.

EDIT:

Ok read your question again and I think this is what you want:

case
      when  [ADDR_EXPR_DATE]='1001-01-01' OR [ADDR_EXPR_DATE] > getdate()  then 'Y'
      else 'N'
    end as active_flag 
Sign up to request clarification or add additional context in comments.

2 Comments

Thank You for your help. it got executed with this statement
Please close this question by clicking the checkmark icon to the top left of this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.