Home Forums SQL Server 2005 T-SQL (SS2K5) Update Datetime Column to Empty String - No Error - Strange Results RE: Update Datetime Column to Empty String - No Error - Strange Results

  • To further expand what Kent was saying. SQL server has explicit and implicit comversions. Explict conversions when you cast or convert a value to another data type. Implicit conversions occur when you do not specify a data type and SQL will automatically convert the value for you to the column data type.

    In your case the string '' is implicitly converted to a 0. The datatime data type in SQL is not stored as you see it when you query the table. A datetime data type is stored as a float value. The float value starts at 0 and works its way upward to today's day.

    e.g.

    declare @dt datetime

    set @dt = getdate()

    select cast(@dt as float)

    The confirmation:

    declare @dt datetime

    set @dt = '1900-01-01 00:00:00.000'

    select cast(@dt as float)