Author Topic: What is different between datetime and datetim2 ?  (Read 3586 times)

kaluahir16

  • Newbie
  • *
  • Posts: 20
    • View Profile
What is different between datetime and datetim2 ?
« on: September 16, 2012, 10:50:42 AM »
DATETIME2 is all most similar to the older DATETIME data type, but it has a greater range and precision. The format is YYYY-MM-DD hh:mm:ss:nnnnnnnm with a range of 0001-01-01 00:00:00.0000000 through 9999-12-31 23:59:59.9999999, and an accuracy of 100 nanoseconds.
Regards,
Kalu Bhuva

Ritesh Shah

  • Administrator
  • Jr. Member
  • *****
  • Posts: 57
  • Ritesh Shah
    • View Profile
    • IT Technology Blog
Re: What is different between datetime and datetim2 ?
« Reply #1 on: September 16, 2012, 03:34:11 PM »
its better to mention SQL Server version which introduces this datatype
Ritesh Shah
Administrator
Extreme-Advice.com
SQLHub.com

BhushanShah

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 73
  • BhushanShah21
    • View Profile
Re: What is different between datetime and datetim2 ?
« Reply #2 on: September 17, 2012, 09:25:17 PM »
As par my information DateTime2 is only available on Sql Server 2008 or later.

For more information about Datetime2 goto below link :

msdn.microsoft.com/en-us/library/bb677335.aspx
« Last Edit: September 17, 2012, 09:27:44 PM by BhushanShah »
Regards,
Bhushan Shah

BhushanShah

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 73
  • BhushanShah21
    • View Profile
Re: What is different between datetime and datetim2 ?
« Reply #3 on: September 18, 2012, 02:41:01 PM »
If you are using Datetime2 as a datatype than you need to use SYSDATETIME() instead of GETDATE().

You can check the difference with following sql statements :

Code: [Select]
select SYSDATETIME()

select GETDATE()
Regards,
Bhushan Shah