Date data types in SQL

OBJECTIVE

In this chapter you will learn:

What is date data type?
Types of date data type

What is date data type?

Sometimes we need to store the date value in our database records then the date data type used to store the date in the specific database or table. There are so many date data types by which we can store date in different format.

 

Data typesRangeUsed to storeStorage (Bytes)
datetimeJanuary 1, 1753, through December 31, 9999Date and time data8
smalldatetimeJanuary 1, 1900, through December 31, 2079Date and time data4
dateJanuary 1, 0001, through December 31, 9999 A.D.Date data3
datetime2January 1, 0001, through December 31, 9999 A.D.Date and time data6 to 8
datetimeoffsetJanuary 1, 0001, through December 31, 9999 A.D.Time zone adware date and time data10
time00:00:00.0000000 through 23:59:59.9999999Time data5
timestampMaximum storage size of 8 bytesUnique number in a database that is updated every time a rows that contains time stamp is inserted or updated8
Year1970 to 2069Store year in two or four digit format

SUMMARY

All date data types are given in this chapter for your help to leran easily. In the next chapter all remaining data type of sql are given into other data types category.


Leave a Reply

Your email address will not be published. Required fields are marked *