Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add 5 days to the current date.
PostgreSQL
SELECT CURRENT_DATE [1] INTERVAL '5 days';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' causes subtraction.
Using '*' or '/' causes syntax errors.
✗ Incorrect
In PostgreSQL, you add intervals to dates using the + operator.
2fill in blank
mediumComplete the code to subtract 2 months from the current date.
PostgreSQL
SELECT CURRENT_DATE [1] INTERVAL '2 months';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' adds the interval instead of subtracting.
Using '*' or '/' causes errors.
✗ Incorrect
Use the minus sign (-) to subtract intervals from dates in PostgreSQL.
3fill in blank
hardFix the error in the code to add 10 hours to the timestamp '2024-01-01 08:00:00'.
PostgreSQL
SELECT TIMESTAMP '2024-01-01 08:00:00' [1] INTERVAL '10 hours';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' subtracts the interval instead of adding.
Using '*' or '/' causes syntax errors.
✗ Incorrect
The plus sign (+) correctly adds the interval to the timestamp.
4fill in blank
hardFill both blanks to subtract 15 days and then add 3 hours to the current timestamp.
PostgreSQL
SELECT CURRENT_TIMESTAMP [1] INTERVAL '15 days' [2] INTERVAL '3 hours';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' to subtract days causes wrong results.
Using '*' or '/' causes errors.
✗ Incorrect
First subtract 15 days using '-', then add 3 hours using '+'.
5fill in blank
hardFill all three blanks to add 1 year, subtract 2 months, and add 10 days to the current date.
PostgreSQL
SELECT CURRENT_DATE [1] INTERVAL '1 year' [2] INTERVAL '2 months' [3] INTERVAL '10 days';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' to add intervals causes wrong results.
Using '*' or '/' causes syntax errors.
✗ Incorrect
Add 1 year with '+', subtract 2 months with '-', then add 10 days with '+'.