CodeBlanks Logo Icon CodeBlanks

DATE and TIME

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

query.sql
-- date column
CREATE TABLE orders (
  order_date

Sample solution

query.sql
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

Question
CREATE TABLE t (d ____);
Answer
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

All lessons in Beginner