User753101303 posted
Hi,
The problem is that this column is still a date column and the empty string is a particular case which is parsed to January 1st 1900..
If you really want to do that in this SQL query you would need to convert MAX(T0.DocDate) to a string using for example
https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql?view=sql-server-ver15 (or CONVERT if using an older SQL Server version) but then you'll get a string later down the road.
My personal preference would be to keep a date and use NULL rather than an empty string:
CASE WHEN T1.ItemCode is null THEN NULL else Max(T0.DocDate) end
Then I still have a date column that I can process or format as I want later.