Complete the code to extract the year from the date column.
SELECT EXTRACT([1] FROM order_date) AS order_year FROM orders;The EXTRACT function with YEAR extracts the year part from a date.
Complete the code to extract the month from the date column.
SELECT EXTRACT([1] FROM shipment_date) AS shipment_month FROM shipments;Use EXTRACT(MONTH FROM ...) to get the month number from a date.
Fix the error in the code to extract the day from the date column.
SELECT EXTRACT([1] FROM shipment_date) AS day_extracted FROM shipments;The correct syntax is EXTRACT(DAY FROM date_column). The FROM keyword must come after the unit.
Fill both blanks to extract the year and month from the date column.
SELECT EXTRACT([1] FROM order_date) AS year, EXTRACT([2] FROM order_date) AS month FROM orders;
Use YEAR to extract the year and MONTH to extract the month from a date.
Fill all three blanks to extract year, month, and day from the date column.
SELECT EXTRACT([1] FROM event_date) AS year, EXTRACT([2] FROM event_date) AS month, EXTRACT([3] FROM event_date) AS day FROM events;
Use YEAR, MONTH, and DAY in that order to extract each part from the date.
