August 1, 2011 at 12:35 pm
How to void displaying ''1900-01-01 00:00:00.000" if datetime data is null?
August 1, 2011 at 12:37 pm
where is that displaying?
zero (0) is SQL's starting date of 1900-01-01, so i suspect that either your query or your application is converting null to zero,a dn displaying that converted datetime value.
Lowell
August 1, 2011 at 12:39 pm
If the datetime is null, SQL will display it as null. It doesn't automatically convert any null value to a non-null value. Something in the query or the display is, or the column is a varchar and = '' (rather than null), which when converted to datetime goes to the 0 date (iirc).
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 1, 2011 at 12:43 pm
Someone creaete a table in which "1900-01-01 00:00:00.000" are in one column (only 30% have real date).
How to code to convert them into null in my new table?
August 1, 2011 at 12:47 pm
will the column support NULLS? if it can, you could update the data to be null where the column is that value.
it really depends on the table and the columns' datatype .
also, will your application crash if it gets a null value for that field, assuming it's trying to populate a datepicker control or something?
UPDATE YOURTABLE
SET ThatColumn = NULL
WHERE ThatColumn = '1900-01-01 00:00:00.000'
Lowell
August 1, 2011 at 12:47 pm
UPDATE <table>
SET <column name> = NULL
WHERE <column name> = '1900-01-01'
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 1, 2011 at 12:47 pm
update table
set datecolfield = null
where datecolfield = '1900-01-01 00:00:00.000'
August 1, 2011 at 12:51 pm
Yes, it works great.
Thank all of you.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply