This is a mirror of official site: http://jasper-net.blogspot.com/

SQL SERVER – DATE and TIME in SQL Server 2008

| Sunday, May 30, 2010
I was thinking about DATE and TIME datatypes in SQL Server 2008. I earlier wrote about the about best practices of the same. Recently I had written one of the script written for SQL Server 2008 had to run on SQL Server 2005 (don’t ask me why!), I had to convert the DATE and TIME datatypes to DATETIME. Let me run quick demo for the same.

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

Read more: Journey to SQL Authority with Pinal Dave

Posted via email from jasper22's posterous

0 comments: