1
votes

SQL Server : when I select my totals row, for date I select ' ' but it gets converted to 1/1/1900 because it is a date column for all other rows. What can i do to make it say blank.

I'm trying to show blank on a total line, on the detail line it's a date. On the total line it's 1/1/1900 so can be confusing. I would like to show blank on the total line.

Here is an example of my total row. some of the blank values are dates in the detail.

UNION ALL 
SELECT  TOP 99999999
AddUpdate
 , Members_SourceCode 
 ,  YearMonth  + ' Total Month' 
, ' ' 
, ' ' 
, ' ' 
, ' ' 
,  ' ' 
, ' ' 
, ' ' 
, ' ' 
, ' ' 
, ' ' 
, ' ' 
, ' ' 
, COUNT(Members_sourceCode) 

GROUP BY AddUpdate, Members_SourceCode, YearMonth
ORDER BY AddUpdate, Members_SourceCode, YearMonth
1
which database and what soruce code are you using - nbk
Date values in SQL either have a value or are NULL. They cannot be blank/empty strings, which is a different thing than NULL. But to provide more info than this about how to show a blank string to the user when the value is NULL we need to see more of your code and design. - Joel Coehoorn

1 Answers

0
votes

Nothing represents the default value of a data type. The default value depends on whether the variable is of a value type or of a reference type.

Nothing keyword (Visual Basic) - Remarks

With VB.NET and EF 6.X to save null is:

Dim nullableData As New Nullable(Of Date)