case statement result a date value

Database
Fan

case statement result a date value

i want to output Date field value (not just a Date format) using a case statement.

 

something like:

when the open_date is before 03/01/2015 and the account_rate is Variable, then output that date value in a new column called 'reviewed_date'

 

i have the case statement mostly done, but I am looking to output the date value, not just a flag or text value.

 

Any suggestions?

2 REPLIES
Teradata Employee

Re: case statement result a date value

What do you mean by "output?"
For a Select statement, just

    select ..., CASE WHEN open_date < date'03/01/2015' AND <the-account_rate-is-Variable> THEN open_date ELSE cast(null as date) END, ...
You can also use CASE in a stored procedure instead of If-Else, but that is different.

Fan

Re: case statement result a date value

By 'Output' I mean the results from the Select statement

 

I will try that...I dont have the code with me now.