Challenge - 5 Problems
Timestamp Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
What is the output of CURRENT_DATE?
Consider the following SQL query run on April 15, 2024:
SELECT CURRENT_DATE;What will be the output?
PostgreSQL
SELECT CURRENT_DATE;Attempts:
2 left
💡 Hint
CURRENT_DATE returns only the date part without time.
✗ Incorrect
CURRENT_DATE returns the current date in the format YYYY-MM-DD without any time component.
❓ query_result
intermediate1:30remaining
What does CURRENT_TIMESTAMP return?
Given the query below executed on April 15, 2024 at 14:30:45.123456:
SELECT CURRENT_TIMESTAMP;What is the expected output format?
PostgreSQL
SELECT CURRENT_TIMESTAMP;Attempts:
2 left
💡 Hint
CURRENT_TIMESTAMP returns date and time with timezone.
✗ Incorrect
CURRENT_TIMESTAMP returns the current date and time including fractional seconds and timezone offset.
❓ query_result
advanced2:00remaining
How does NOW() differ from CURRENT_TIMESTAMP?
Run these two queries at the same moment:
SELECT NOW(); SELECT CURRENT_TIMESTAMP;What is the difference in their outputs?
PostgreSQL
SELECT NOW(); SELECT CURRENT_TIMESTAMP;
Attempts:
2 left
💡 Hint
In PostgreSQL, NOW() is an alias for CURRENT_TIMESTAMP.
✗ Incorrect
In PostgreSQL, NOW() and CURRENT_TIMESTAMP are equivalent and return the same timestamp with timezone.
📝 Syntax
advanced2:00remaining
Which query correctly extracts only the date part from NOW()?
You want to get only the date (YYYY-MM-DD) from the current timestamp using NOW(). Which query is correct?
Attempts:
2 left
💡 Hint
PostgreSQL allows multiple ways to extract date from timestamp.
✗ Incorrect
All options correctly extract the date part from NOW(): casting, DATE() function, and formatting.
🧠 Conceptual
expert2:30remaining
Why might CURRENT_TIMESTAMP and NOW() return different values inside a transaction?
In PostgreSQL, consider a transaction that runs multiple queries using NOW() and CURRENT_TIMESTAMP. Which statement is true?
Attempts:
2 left
💡 Hint
PostgreSQL treats NOW() and CURRENT_TIMESTAMP as transaction start time.
✗ Incorrect
In PostgreSQL, NOW() and CURRENT_TIMESTAMP return the time at the start of the current transaction, so multiple calls inside the same transaction return the same timestamp.