Date Value RRS feed

  • Question

  • User1979860870 posted


      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 


    Wednesday, November 4, 2020 5:21 AM

All replies

  • User753101303 posted


    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.

    Wednesday, November 4, 2020 8:13 AM