DATE and TIME
- SQL course
- Beginner
- Lesson 27/115
- 4 min
Learn date and time types.
DATE and TIME
DATE holds a date, TIME a time, TIMESTAMP both. The date format is YYYY-MM-DD.
CREATE TABLE orders (
order_date DATE,
order_time TIME,
created_at TIMESTAMP
);Order_date holds the date, order_time the time, created_at both.
The table orders is created.
DATE and TIME — details
Date literals go in single quotes: '2026-01-15'. TIMESTAMP can be auto-updated; with DEFAULT CURRENT_TIMESTAMP it fills at insert time.
Practice DATE and TIME
Add an order_date DATE column to orders.
Starter code
-- date column
CREATE TABLE orders (
order_dateSample solution
CREATE TABLE orders (
order_date DATE
)Expected output
Tablo oluşturuldu
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the DATE format?
- DD-MM-YYYY
- MM/DD/YYYY
- YYYY-MM-DD Correct answer
- YYYY/MM/DD
Explanation: DATE format is YYYY-MM-DD.
2 Date type
CREATE TABLE t (d ____);
CREATE TABLE t (d DATE);
Explanation: DATE stores only a date (year-month-day).
3 DATE and TIME: match the terms
| Term | Meaning |
|---|---|
DATE |
date |
TIME |
time |
TIMESTAMP |
date+time |
INT |
integer |