Datetime Data Types in SQL Server with Examples or Date and Time Data Types in SQL Server

  Total Views : 421
  Comments : 0
 
  Keywords : SQL server date and time data types, SQL server datetime datatypes, Use date and time data types in sql server,Examples of datetime datatypes in sql server

Here we will learn datetime datatypes in sql server or date and time datatypes in sql server.

SQL Date and Time Data Types

In SQL server we will use these data types whenever we want to store date or date and time in column. We have different type of date and time data types those are 

 

                        - smalldatetime

 

                        - datetime

 

                        - datetime2

 

                        - date

 

                        - time

 

                        - datetimeoffset

 

Please check following table for more details regarding date and time data types in sql server

 

Data TypeDescriptionStorage Size
smalldatetime We can store values From January 1, 1900 to June 6, 2079 and it’s having accuracy of 1 minute 4 Bytes
datetime We can store values from January 1, 1753 to December 31, 9999 and it’s having accuracy of 3.33 milliseconds 8 Bytes
datetime2 We can store values from January 1, 0001 to December 31, 9999 and it’s having accuracy of 100 nanoseconds 6 - 8 Bytes
date We can store only date format like May 05, 1986 and the range is from January 1, 0001 to December 31, 9999 3 Bytes
time We can store only time format like 12.00 PM 3 - 5 Bytes
datetimeoffset It’s same as datetime2 with the addition of a time zone offset 8 - 10 Bytes

DateTime Datatype Example Formats in SQL Server

Please check following table for date and time data types example formats in sql server

 

Data TypeExample Format
smalldatetime 2007-05-08 12:35:00
datetime 2007-05-08 12:35:29.123
datetime2 2007-05-08 12:35:29. 1234567
date 2007-05-08
time 12:35:29. 1234567
datetimeoffset 2007-05-08 12:35:29.1234567 12:15

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User