Last post Nov 04, 2020 08:13 AM by PatriceSc
Nov 04, 2020 05:21 AM|jagjit saini|LINK
I have below code and Data is displayed as 1900-01-01 00:00:00.000 but i want BLANK SPACE
CASE WHEN T1.ItemCode is null THEN '' else Max(T0.DocDate) end
Nov 04, 2020 08:13 AM|PatriceSc|LINK
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.