Tuesday, August 20, 2013

TSQL Interview Questions: DateTime

There are two types of datetime data types


Stores dates from January 1, 1753 through December 31, 9999, to an accuracy of one three-hundredth of a second (equivalent to 3.33 milliseconds or 0.00333 seconds). Values are rounded to increments of .000, .003, or .007 seconds, as shown in the table.

Small Datetime

Stores dates from January 1, 1900, through June 6, 2079, with accuracy to the minute. smalldatetime values with 29.998 seconds or lower are rounded down to the nearest minute; values with 29.999 seconds or higher are rounded up to the nearest minute.

Internally SQL server stores Datetime data in 2 4 bytes integers and smalldatetime stores as 2 2 byte integers. One part stores days before or after base date and next part stores the number of milliseconds after midnight.

No comments:

Post a Comment