The Database Knowledgebase on the Web

KNOWLEDGEBASE:

SQL

Oracle

MySQL

Postgres 

General topics 

Glossary 

SQL

Data Types

Date

In some databases, a DATE stores only a date but in others it can store date and time. In those databases where it stores date only, there is usually a separate data type called DATETIME (or something close to that).

Dates (and times) are usually stored internally as binary numbers. They really do not have a format until query time. When queried, the database or client will automatically format the date using a default format mask (ex. DD-MON-YYYY or MM/DD/YYYY). It is always best to explicitly format your dates and times when querying them to avoid misunderstandings. I show how to do that below in the sections on expressions and functions.

A related data type that stores dates and times is the Timestamp. While most DATETIME data types will stored time down to the seconds, a Timestamp stores minute fractions of time. Timestamps may also store timezone information.

Topic: String Number Date Boolean

Topics:

Contact: Lewis Cunningham
lewisc@databasewisdom.com

About us

Contact us

Support us

Search Database Wisdom