Complete the code to extract the year from the date column.
SELECT EXTRACT([1] FROM order_date) AS year FROM orders;The EXTRACT function extracts the specified part from a date or timestamp. Here, 'year' extracts the year part.
Complete the code to extract the month from the timestamp column.
SELECT EXTRACT([1] FROM created_at) AS month FROM users;To get the month part from a timestamp, use EXTRACT with 'month'.
Fix the error in the code to correctly extract the day from the date column.
SELECT EXTRACT([1] FROM order_date) AS day FROM orders;The correct keyword to extract the day is 'day'. 'days' or 'date' are invalid in EXTRACT.
Fill both blanks to extract the hour and minute from the timestamp column.
SELECT EXTRACT([1] FROM login_time) AS hour, EXTRACT([2] FROM login_time) AS minute FROM sessions;
Use 'hour' to get the hour part and 'minute' to get the minutes from a timestamp.
Fill all three blanks to extract year, month, and day from the birth_date column.
SELECT EXTRACT([1] FROM birth_date) AS year, EXTRACT([2] FROM birth_date) AS month, EXTRACT([3] FROM birth_date) AS day FROM people;
Use 'year', 'month', and 'day' to extract these parts from a date.