Introduction
Dates
Time
Timestamps
Extract functions
Timezone conversion
Intervals
35. BETWEEN WITH INTERVALS – additional practice
Current date and time
Revision

Instruction

Good job. BETWEEN is often used with intervals when we want to find facts for a specific month. We no longer need to check whether a given month has 28, 29 (February), 30 or 31 days, the database will do that for us.

SELECT id
FROM aircraft
WHERE produced BETWEEN '2010-01-01'
  AND CAST('2010-01-01' AS date) + INTERVAL '1' MONTH;

Check it out for yourself!

Exercise

Count the number of flights performed in August 2015.

Console

Code editor

Result

TableConsole