|
Did the storage of DATETIME in SQL Server change from being a FLOAT to a new data type?
(comments are locked)
|
|
Are you concerned about implicit and explicit conversions, and if they've changed from an older version of SQL? The conversion charts are shown at http://msdn.microsoft.com/en-us/library/ms187928.aspx for SQL 2008 R2, and http://msdn.microsoft.com/en-us/library/aa226054(v=sql.80).aspx for SQL 2000. Doesn't seem to show any differences between the way dates are converted to floats, though. @Raj More - what's the actual problem?
(comments are locked)
|
|
DATETIME is stored as 8 bytes: http://msdn.microsoft.com/en-us/library/ms187819.aspx FLOAT is a datatype and is stored in either 4 or 8 bytes : http://msdn.microsoft.com/en-us/library/ms173773.aspx Are you getting datatypes and storage mixed up?
(comments are locked)
|
|
The storage if DATETIME is, like all other data types, a number of bytes. For a DATETIME it's eight bytes, where I think the first four bytes store the number of days since January 1st 1900 and the other four bytes are the number of milliseconds since midnight.
(comments are locked)
|


@Raj More It has never been a float in any version. I pimped the link to my script in the comment to @Kevin Feasel's answer, it shows how datetime values are stored.
@Oleg: you're right. I deleted my answer to reduce any confusion (not just to cover up when I'm wrong...err...).
The link that @Oleg mentioned was http://ask.sqlservercentral.com/questions/16420/php-with-mssql-strtotime-with-mssql-datetime-column.
@Kevin Feasel This was a good answer as it has shown that it is possible to convert the float to datetime. The only difference is that in this case the digits before the decimal point (the float value cast as int) go to the left int (number of days) and the digits after the decimal point are used to calculate the ticks past midnight (([float value] - [float value cast as int]) * max_ticks cast as int and then fed to the right int)