December 14, 2010 at 12:03 pm
My asp.net program export a table to Excel in which null datetime data became "1/1/1900 12:00:00 AM" as default. How to keep null (blank) in stead of "1/1/1900 12:00:00 AM"?
December 14, 2010 at 12:33 pm
I am not sure what method you are using to export the data, but one way is change the dates to an empty string when they are null.
something like:
select case when columnDate is NULL then '' else columnDate end as yourDate
from table
The probability of survival is inversely proportional to the angle of arrival.
December 14, 2010 at 12:52 pm
I tested it but became 'Jan 1 1900 12:00AM'
December 14, 2010 at 1:18 pm
adonetok (12/14/2010)
I tested it but became 'Jan 1 1900 12:00AM'
The reason is rather simple:
Internally, SQL Server stores datetime values as two 4-byte integers (see BOL for details).
A blank string assigned to an integer data type will be converted to Zero (0). And Zero (0) for a datetime value means '1900-01-01 12:00AM'.
In order to replace NULL values with a blank you'd need to convert your result to a character data type first (using CONVERT). Then you can use ISNULL(converted_column,'').
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply