Pages

Search This Blog

Thursday, August 5, 2010

[T-SQL] DATE and TIME in SQL Server 2008

Example of Date and Time

DECLARE @varDate AS DATE
DECLARE @varTime AS TIME
SET @varDate = '10/10/2010'
SET @varTime = '12:12:12'
SELECT CAST(@varDate AS DATETIME) C_Date
SELECT CAST(@varTime AS DATETIME) C_Time

Result would be

2010-10-10 00:00:00
1900-01-01 12:12:12

No comments: