Complete the code to select the current date in PostgreSQL.
SELECT [1];In PostgreSQL, CURRENT_DATE returns the current date without time.
Complete the code to extract the year from a date column named 'order_date'.
SELECT EXTRACT([1] FROM order_date) AS year FROM orders;The EXTRACT function with year extracts the year part from a date.
Fix the error in the code to add 7 days to the current date.
SELECT CURRENT_DATE + [1];In PostgreSQL, to add days to a date, you add an INTERVAL value like INTERVAL '7 days'.
Fill both blanks to convert a text '2024-06-15' to a date and then extract the month.
SELECT EXTRACT([1] FROM [2]('2024-06-15')) AS month;
Use EXTRACT(month FROM ...) to get the month, and cast to ::date to convert text to date.
Fill all three blanks to calculate the difference in days between two dates '2024-06-20' and '2024-06-15'.
SELECT ([1]('2024-06-20') - [2]('2024-06-15')) [3] '1 day' AS days_diff;
Cast the strings to DATE, subtract them, and cast the result to interval type to get the difference in days.