DATE TIME DATA DTYPE SQL SERVER 2005
DATE TIME DATA DTYPE SQL SERVER 2005.
Among All the date type in all the applications/systems the data/time change in which the application changes.As we all know that information systems change over time.The Datetime plays a major role in the BI ,OLAP systems and in Datawharehousing systems.So letus take more granular look in the Date Time datatype.
In SQL Server 2005 we have 2 variants of datatype DATETIME SMALLDATETIME.DATETIME:
Is 8 bytes in size and contains the 2 parts first(4 bytes) the ,number of days before or after the base date: January 1, 1900.And second(next four bytes) part contains the 4 bytes store the time of day represented as the number of 1/300-second units after midnight.SMALLDATETIME:
Is 4 bytes in size and contains the 2 parts first(2 bytes) the,number of days before or after the base date: January 1, 1900.And second(next TWO bytes) part contains the 2 bytes store the number of minutes since midnight.
SELECT CAST(getdate() AS datetime) ,CAST(getdate() AS smalldatetime);
2008-11-21 20:08:23.963 2008-11-21 20:08:00
We have getdate() built-in function which gets the date time based on the underlying datatype. Converted or assigned on the LHS of the assignement.
SELECT CAST(getdate() AS datetime) ,CAST(getdate() AS smalldatetime);
"2008-11-21 20:08:23.963" "2008-11-21 20:08:00"