Skip to content
Advertisement

Case when date = current_date then text

I have a table like this:

But when I execute this query:

I get this result:

SQL Fiddle

I would expect that in the rows where is_equal is true, the result should be TODAY. What am I doing wrong?

Advertisement

Answer

Nevermind, I solved it, but I don’t want to discard the question. The solution is to CAST(token_date as varchar) in the else clause

Edit: See @a_horse_with_no_name ‘s comment – it is better to use the to_char function to format the date to get a consistent output.
E.g. to_char(token_date, 'yyyy-mm-dd')

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement