Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dealing with dates
Working with time data
Date and time date
Extracting dates and times
Doing arithmetic with dates
Converting date and time data
Current date and time data
Building date and time data from parts
Summary and review

Instruction

Fantastic! How can we use these functions in our queries? We can use them to explore things that which took place in the last week, last month, and so on. Take a look:

SELECT
  Id
FROM Flight
WHERE Date > DATEADD(day, -7, current_timestamp);

The above query will find all flights that took place in the last 7 days.

Exercise

Find the IDs of all the aircraft that were produced more than three months ago.

Stuck? Here's a hint!

Use the DATEADD() function on the CURRENT_TIMESTAMP column. The datepart argument should be month.