.NET Logo
Welcome Guest Search | Active Topics | Members | Log In | Register

SQL Server 2008: Date and Time Data Types Options · View
ball
Posted: Thursday, February 07, 2008 11:30:50 AM

Rank: อาจารย์
Groups: Administration

Joined: 12/1/2007
Posts: 462
Location: Bangkok

Date and Time Data Types

  • DateTime

New in SQL Server 2008

  • Date
  • Time
  • DateTime2
  • DateTimeOffset
--DATE
DECLARE @DateTime datetime
SELECT @DateTime = GETDATE()
PRINT @DateTime

DECLARE @Date1 date
SELECT @Date1 = GETDATE()
PRINT @Date1

DECLARE @Date2 date
SELECT @Date2 = '2007-08-03'
PRINT @Date2

 

--TIME
DECLARE
    @MyTime time = GETDATE(),
    @MyTime7 time(7) = GETDATE(),
    @MyTime6 time(6) = GETDATE(),
    @MyTime5 time(5) = GETDATE(),
    @MyTime4 time(4) = GETDATE(),
    @MyTime3 time(3) = GETDATE(),
    @MyTime2 time(2) = GETDATE(),
    @MyTime1 time(1) = GETDATE(),
    @MyTime0 time(0) = GETDATE()

PRINT @MyTime
PRINT @MyTime7
PRINT @MyTime6
PRINT @MyTime5
PRINT @MyTime4
PRINT @MyTime3
PRINT @MyTime2
PRINT @MyTime1
PRINT @MyTime0

--DATETIME2
DECLARE @datetime2 as DATETIME2(7) = GETDATE()
PRINT @datetime2

--DATETIMEOFFSET
DECLARE @datetimeoffset as DATETIMEOFFSET(7) = '2007-11-06 14:30:00 -06:00'
PRINT @datetimeoffset


Imagination is more Important than Knowledge... /A.Einstein
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.


Sponsored by