SQLEXTRACTdatetutorial

What is EXTRACT in SQL? Year, month, day from a date for beginners

EXTRACT pulls a piece out of a date: year, month, day, hour, day of week. Plain words: how to group by year/month, filter by weekday, count seconds via EPOCH. Compared with DATE_TRUNC and PostgreSQL/MySQL differences.

1 min readSQL · EXTRACT · date · tutorial

EXTRACT is the standard SQL way to pull a single component out of a date or timestamp. Year, month, day, hour, day of week — anything you can name in a date can come out as a number.

This article is currently in Russian. The full English translation is on the way.

Practice on real tasks

Solve tasks in the SQL trainer with instant grading and hints.

Open trainer