declare @d datetime , @days int , @msec int select @d = current_timestamp select @d AS thisisthedatetime
select @days = cast( substring( cast( @d as varbinary ) , 1 , 4 ) as int ) , @msec = cast( substring( cast( @d as varbinary ) , 5 , 4 ) as int ) select @Days AS dayssince1900 , @msec AS msecsincemidnight
select datepart( yy , dateadd( dd, @days , '1900-01-01') ) as "Year" , datepart( mm , dateadd( dd, @days , '1900-01-01') ) as "Month" , datepart( dd , dateadd( dd, @days , '1900-01-01') ) as "Day" , @msec / ( 300 * 60 * 60 ) AS Hours , ( @msec % ( 300 * 60 * 60 ) ) / ( 300 * 60 ) AS Minutes , ( ( @msec % ( 300 * 60 * 60 ) ) % ( 300 * 60 ) ) / ( 300) AS Seconds , convert( int , round ( (( ( ( @msec % ( 300 * 60 * 60 ) ) % ( 300 * 60 ) ) % ( 300 )) / 3. ) * 10 , 0 ) ) AS MilliSeconds
|