Wednesday, January 20, 2021

DATETIME vs DATETIME2 - 5 reasons why DATETIME2 is better

Recommendation first: if you are not sure whether to choose Datetime or Datetime2 the answer is choose Datetime2. Why?
  1. Higher precision – up to 7 fractional digits for datetime2 vs 3 for datetime 
  2. Higher level of accuracy – datetime rounds the last digit to an increment of .000, .003 or .007 whereas datetime2 supports accuracy of 100 nanoseconds 
  3. Wider range of values – datetime2 supports dated from 0001-01-01 00:00:00 to 9999-12-31 23:59:59.9999999 whereas datetime supports dates from 1753-01-01 00:00:00 to 9999-12-31 23:59:59.997 
  4. Space requirements – depending on the fractional precision you require datetime2 needs from 6 Bytes to 8 bytes of space whereas datetime requires 8 bytes 
  5. Compliance with standards: datetime2 is compliant with both ANSI and ISO 8601 whereas datetime is not.
For a more in depth review of those reasons you can check our other post here.

0 comments:

Post a Comment