Thinking outside the box

Patron Saint of Lost Yaks
posts - 203, comments - 734, trackbacks - 4

My Links

Advertisement

News

Archives

Post Categories

The internal storage of a DATETIME value

SELECT  [Now],
        BinaryFormat,
        SUBSTRING(BinaryFormat, 1, 4) AS DayPart,
        SUBSTRING(BinaryFormat, 5, 4) AS TimePart,
        CAST(SUBSTRING(BinaryFormat, 1, 4) AS INT) AS [Days],
        DATEADD(DAY, CAST(SUBSTRING(BinaryFormat, 1, 4) AS INT), 0) AS [Today],
        CAST(SUBSTRING(BinaryFormat, 5, 4) AS INT) AS [Ticks],
        DATEADD(MILLISECOND, 1000.E / 300.E * CAST(SUBSTRING(BinaryFormat, 5, 4) AS INT), 0) AS Peso
FROM    (
            SELECT  GETDATE() AS [Now],
                    CAST(GETDATE() AS BINARY(8)) AS BinaryFormat
        ) AS d

Print | posted on Friday, November 05, 2010 3:10 PM | Filed Under [ SQL Server 2008 Algorithms SQL Server 2005 SQL Server 2000 ]

Feedback

Gravatar

# re: The internal storage of a DATETIME value

How are you going to convert int value into datetime?
7/7/2011 11:17 PM | Naomi
Gravatar

# re: The internal storage of a DATETIME value

You mean an INT like 20110707? Not easily since an integer doesn't follow 12 month rule per year.
7/7/2011 11:31 PM | Peso
Gravatar

# re: The internal storage of a DATETIME value

This post might be a good read if you just posted some description on the codes you wrote here.
8/28/2012 1:12 PM | a good thesis from Essay 24/7
Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET