CONVERT (varbinary(8), @today) : VARBINARY « Data Types « SQL Server / T-SQL Tutorial






31> DECLARE @today datetime
32> SELECT @today = current_timestamp
33>
34> SELECT @today
35> SELECT CONVERT (varbinary(8), @today)
36> SELECT CONVERT (int, SUBSTRING (CONVERT (varbinary(8), @today), 1, 4))
37> SELECT CONVERT (int, SUBSTRING (CONVERT (varbinary(8), @today), 5, 4))
38> GO

-----------------------
2008-08-17 13:14:21.513

(1 rows affected)



--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
0x00009AFB00DA2D56



(1 rows affected)

-----------
      39675

(1 rows affected)

-----------
   14298454

(1 rows affected)
1>








5.26.VARBINARY
5.26.1.Binary Data Types
5.26.2.VARBINARY(MAX)
5.26.3.VARBINARY type variable
5.26.4.CONVERT (varbinary(8), @today)