Problems Converting a date to dd/mm/yy

Hello everyone,

I have a column named t.value that is the data type (varchar(255), null. Sometimes the column will contain dates entered in the format yyyy-mm-dd. I am using this column in a case statement and need the date formatted as dd/mm/yy .

My query

t.team,
t.value,
MAX(CASE WHEN t.salesid = 73 THEN t.value ELSE '' END) AS ‘Date_1’

FROM team t
INNER JOIN order_book b
ON t.orderid = b.orderid
GROUP BY
t.team,
t.value

I have tried re-writing the case statement as follows:

MAX(CASE WHEN t.salesid = 73 THEN convert(varchar,(t.value), 103) ELSE '' END) AS 'Date_1’

This does not appear to make any difference to the format when I run the query.

How can I make this work in my case statement? Any help would be much appreciated.

Vinnie

MAX(CASE WHEN t.salesid = 73 THEN convert(varchar,CAST(t.value AS date)), 103) ELSE '' END) AS 'Date_1’

Thanks for your response but this generates an incorrect syntax error near ','.

Sorry, extra right paren:

MAX(CASE WHEN t.salesid = 73 THEN convert(varchar,CAST(t.value AS date ), 103) ELSE '' END) AS 'Date_1’

Thank you - works perfectly now